HDU 1893 Sibonacci Numbers(斐波那契)

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 # include<stdio.h>
 2 # 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         else
26         {
27             x=x*100;
28             y=(int)(x+eps);
29                 printf("%I64d\n",a[y]);
30         }
31     }
32     return 0;
33 }

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值