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 | #include <iostream> using namespace std; int cnt0, cnt1; int fibonacci(int n) { if (n==0) { cnt0++; return 0; } else if (n==1) { cnt1++; return 1; } else { return fibonacci(n-1) + fibonacci(n-2); } } int main(int argc, char *argv[]) { int T, N; cin >> T; for(int t_case=0; t_case < T; t_case++) { cnt0 = 0; cnt1 = 0; cin >> N; fibonacci(N); cout << cnt0 << " " << cnt1 << endl; } } | cs |
'C & C++ > Baekjoon' 카테고리의 다른 글
백준 1110 - 더하기 사이클 (0) | 2017.12.27 |
---|---|
백준 1065 - 한수 (0) | 2017.12.27 |
백준 1008 - A/B (0) | 2017.12.27 |
백준 1001 - A-B (0) | 2017.12.27 |
백준 1000 - A+B (0) | 2017.12.27 |