题意:给你斐波那契数列的前15项(1,2,3,5,8...) ,给出一个和SUM,从这15个数字中取出一些数字,使他们的和=SUM,问有多少种方案。
解析:完全背包
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
using namespace std;
#define esp (1e-6)
#define LL long long
#define pi acos(-1.0)
#define ALL(a) (a.begin(),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,-1,sizeof(a))
#define IOS cin.tie(0),cout.sync_with_stdio(0)
#define PRINT(a,b) cout << "\n#" << (a) << " " << (b) << endl
//#define DEBUG(a,b) cout << "$" << (a) << " " << (b) << endl
#define lin cout << "\n--------------------\n"
const LL LLINF = 1e18+100;
const int INF = 0x3f3f3f3f;
const int MAXN = 3e3 + 5;
const int MOD = 1e9+9;
int fib[20];
int dp[20][MAXN];
void init(){
fib[1] = fib[0] = 1;
fib[2] = 2;
for(int i=3; i<=16; ++i) {
fib[i] = fib[i - 1] + fib[i - 2];
//printf("#%d %d\n",i, fib[i]);
}
ZERO(dp);
for(int i=1; i<=3000; ++i) dp[1][i] = 1;
for(int i=0; i<=15; ++i) dp[i][0] = 1;
for(int i=2; i<=15; ++i){
for(int j=0; j<=3000; ++j){
dp[i][j] = dp[i-1][j]%MOD;
if(j >= fib[i]){
dp[i][j] += dp[i][j-fib[i]]%MOD;
dp[i][j] %= MOD;
}
}
}
}
int main()
{
init();
int t, n;
cin >> t;
while(t--){
scanf("%d", &n);
printf("%d\n", dp[15][n]);
}
return 0;
}