-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path_10870.java
More file actions
39 lines (36 loc) ยท 801 Bytes
/
_10870.java
File metadata and controls
39 lines (36 loc) ยท 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package backjoon;
// https://www.acmicpc.net/problem/10870
// ํผ๋ณด๋์น ์ 5
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class _10870 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
// memory 11468 runtime 84
int n = Integer.parseInt(br.readLine());
int first = 0;
int second = 1;
int fibonacci = first + second;
if(n==0){
System.out.println(0);
}
if(n==1){
System.out.println(1);
}
if(n>1){
for(int i=1; i<n; i++){
fibonacci = first + second;
first = second;
second = fibonacci;
}
System.out.println(fibonacci);
}
}
}
/*
input
10
output
55
*/