// Copyright © 2021 ์์ฃผํ. All rights reserved.
//
// https://www.acmicpc.net/problem/1003
// BOJ1003 ํผ๋ณด๋์น ํจ์
#include <iostream>
#include <vector>
using namespace std;
int dp[41][2] = { {1,0},{0,1} }; // dp[0][0]=1; dp[0][0]=0; dp[1][0]=0; dp[1][1]=1;
//num:0 ์ผ๋ 0์ด ์ถ๋ ฅ๋๋๊ฒฝ์ฐ 1๊ฐ 1์ด ์ถ๋ ฅ๋๋ ๊ฒฝ์ฐ0๊ฐ
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int T; cin >> T;
while (T--) {
int N; cin >> N;
for (int i = 2; i <=N; i++) {
dp[i][0] = dp[i - 1][0] + dp[i - 2][0]; //0์ด ์ฌ์ฉ๋๋ ๊ฐฏ์ ์ ์ฅ
dp[i][1] = dp[i - 1][1] + dp[i - 2][1]; //1์ด ์ฌ์ฉ๋๋ ๊ฐฏ์ ์ ์ฅ
}
cout << dp[N][0] << " " << dp[N][1] << "\n";
}
}
'Algorithm ๐ง๐ปโ๐ป > ๋ฐฑ์ค(BOJ)' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค,c++] 1015๋ฒ - ์์ด ์ ๋ ฌ (0) | 2021.10.16 |
---|---|
[๋ฐฑ์ค,c++] 1012๋ฒ - ์ ๊ธฐ๋ ๋ฐฐ์ถ (0) | 2021.10.16 |
[๋ฐฑ์ค,c++] 1010๋ฒ - ๋ค๋ฆฌ ๋๊ธฐ (0) | 2021.10.16 |
[๋ฐฑ์ค,c++] 1009๋ฒ - ๋ถ์ฐ์ฒ๋ฆฌ (0) | 2021.10.16 |
[๋ฐฑ์ค,c++] 1005๋ฒ - ACM Craft (0) | 2021.10.16 |
[๋ฐฑ์ค,c++] 10026๋ฒ - ์ ๋ก์์ฝ (0) | 2021.10.16 |
๋๊ธ