euisblue
9507. Generations of Tribbles

9507 - Generations of Tribbles

꿍은 군대에서 진짜 할짓이 없다. 그래서 꿍만의 피보나치를 만들어보려고 한다. 기존의 피보나치는 너무 단순해서 꿍은 좀더 복잡한 피보나치를 만들어보고자 한다. 그래서 다음과 같은 피보나치를 만들었다. 꿍만의 피보나치 함수가 koong(n)이라고 할 때,

1n < 2 : 1 2n = 2 : 2 3n = 3 : 4 4n > 3 : koong(n − 1) + koong(n − 2) + koong(n − 3) + koong(n − 4)

이다.

여러분도 꿍 피보나치를 구해보아라.

C++

1#include <bits/stdc++.h> 2using namespace std; 3 4#define ull unsigned long long 5#define rep(i,n) for(ll i=0;i<(n);++i) 6#define rep2(i,a,n) for(ll i=a;i<(n);++i) 7#define ios cin.tie(NULL), ios_base::sync_with_stdio(false) 8#define cfs(n) cout<<fixed<<setprecision((n)) 9#define endl '\n' 10 11int main(){ 12 ios; cfs(15); 13 ull koong[69] = {1, 1, 2, 4}; 14 string n69 = "26221385490337611456"; 15 for(int i=4; i<69; ++i) { 16 koong[i] = koong[i-4] + koong[i-3] + koong[i-2] + koong[i-1]; 17 } 18 19 int t; cin >> t; 20 while(t--) { 21 int n; cin >> n; 22 if(n==69) cout << n69 << endl; 23 else cout << koong[n] << endl; 24 } 25 26 27 return 0; 28}