题目链接:http://acm.hust.edu.cn/problem.php?id=1003
As is known to all, the definition of Fibonacci Numbers is:
f(1)=1
f(2)=1
f(n)=f(n-1)+f(n-2) (n>=3)
Now Sempr found another Numbers, he named it "Sibonacci Numbers", the definition is below:
f(x)=0 (x<0)
f(x)=1 (0<=x<1)
f(x)=f(x-1)+f(x-3.14) (x>=1)
求f(n)
结果对1000000007取余数
这个转换成整数,然后注意精度,貌似不需要用long long
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#define eps 1e-8
using namespace std;
const int maxn = 100010;
const int mod = 1000000007;
int rec[maxn];
int init(){
int i,j,k;
for(i=0;i<314;i++)
rec[i]=1;
for(i=314;i<maxn;i++)
rec[i]=(rec[i-100]+rec[i-314])%mod;
return 0;
}
int main(){
int i,j,k,ans,t;
double w;
init();
scanf("%d",&t);
while(t--){
scanf("%lf",&w);
if(w<0){
printf("0\n");
continue;
}
ans=int((w+eps)*100);
printf("%d\n",rec[ans]);
}
return 0;
}