๋ฐ์ํ
https://www.acmicpc.net/problem/9625
์ฝ๋
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int K = scan.nextInt();
int[] aArr = new int[45]; // A์ ๊ฐ์
int[] bArr = new int[45]; // B์ ๊ฐ์
aArr[0] = 0;
aArr[1] = 1;
bArr[0] = 1;
bArr[1] = 1;
for(int i=2; i<45; i++) {
aArr[i] = aArr[i-2] + aArr[i-1];
bArr[i] = bArr[i-2] + bArr[i-1];
}
System.out.println(aArr[K-1] + " " + bArr[K-1]);
scan.close();
}
}
ํ์ด
K๋ฅผ 6์ ๋๊น์ง๋ง ์ ์ด๋ณด๋ฉด ํผ๋ณด๋์น ์์ด์ด๋ผ๋ ๊ท์น์ ์ฐพ์ ์ ์๋ค.
๋ฐ๋ผ์ ๋ชจ๋ ๊ฐฏ์๋ฅผ ๋ค ์ ์ฅํด๋๊ณ ์ถ๋ ฅํ๋ฉด ๋.
๋ฐ์ํ
'Algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค] 1475๋ฒ: ๋ฐฉ ๋ฒํธ(๋ฌธ์์ด, ๊ตฌํ) (0) | 2020.02.05 |
---|---|
ํ๋ก๊ทธ๋๋จธ์ค[Java] - ๊ตฌ๋ช ๋ณดํธ(๊ทธ๋ฆฌ๋) (0) | 2020.02.04 |
[๋ฐฑ์ค] 1783๋ฒ: ๋ณ๋ ๋์ดํธ(๊ทธ๋ฆฌ๋, ๊ตฌํ) (0) | 2020.02.04 |
[๋ฐฑ์ค] 2667๋ฒ: ๋จ์ง๋ฒํธ๋ถ์ด๊ธฐ(๊ทธ๋ํ, DFS) (0) | 2020.02.03 |
[๋ฐฑ์ค] 1049๋ฒ: ๊ธฐํ์ค(๊ทธ๋ฆฌ๋, ๊ตฌํ) (0) | 2020.02.03 |
๋๊ธ