Sibonacci Numbers
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 706 Accepted Submission(s): 242
Problem Description
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) Your work is to tell me the result of f(x), is the answer is too large, divide it by 1000000007 and give me the remainder. Be careful the number x can be an integer or not.
Input
In the first line there is an Integer T(0<T<=10000) which means the number of test cases in the input file. Then followed T different lines, each contains a number x(-1000<x<1000).
Output
For each case of the input file, just output the result, one for each line.
Sample Input
3
-1
0.667
3.15
Sample Output
0
1
2
巧妙点在于以0.01为下标,哈哈,这是相当不理解的吧
再有就是精度问题,错了好几次的
View Code
1 # include2 # define inf 1000000007 3 const double eps=1e-8; 4 __int64 a[100005]; 5 void init(){ 6 int i; 7 for(i=0;i<=313;i++) 8 a[i] = 1; 9 for(i=314;i<=100000;i++){10 a[i]= a[i-100] + a[i-314];11 a[i]=a[i]%inf;12 }13 }14 int main(){15 int T,y,i;16 double x;17 init();18 scanf("%d",&T);19 while(T--){20 scanf("%lf",&x);21 if(x<0)22 printf("0\n");23 else if(x<1)24 printf("1\n");25 else26 {27 x=x*100;28 y=(int)(x+eps);29 printf("%I64d\n",a[y]);30 }31 }32 return 0;33 }