码迷,mamicode.com
首页 > 其他好文 > 详细

1003 - Sibonacci Numbers

时间:2015-06-04 09:51:47      阅读:130      评论:0      收藏:0      [点我收藏+]

标签:算法

1003 - Sibonacci Numbers

Time Limit: 1s Memory Limit: 64MB

Submissions: 2130 Solved: 360
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



  1. #include<stdio.h>
  2. #define MAXN 100000
  3. int a[MAXN];
  4.  
  5. int main()
  6. {
  7. int t,i,k;
  8. double x;
  9. for(i=0;i<314;i++)
  10. {
  11. a[i]=1;
  12. }
  13. for(i=314;i<MAXN;i++)
  14. {
  15. a[i]=a[i-100]+a[i-314];
  16. a[i]%=1000000007;
  17. }
  18. scanf("%d",&t);
  19. while(t--)
  20. {
  21. scanf("%lf",&x);
  22. if(x<0)
  23. {
  24. printf("0\n");
  25. continue;
  26. }
  27. x*=100;
  28. k=(int)(x+0.000001);
  29. printf("%d\n",a[k]);
  30. }
  31. return 0;
  32. }

1003 - Sibonacci Numbers

标签:算法

原文地址:http://blog.csdn.net/zmrlinux/article/details/46353865

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!