博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU 1893 Sibonacci Numbers(斐波那契)
阅读量:7021 次
发布时间:2019-06-28

本文共 1636 字,大约阅读时间需要 5 分钟。

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

 

转载地址:http://wcbxl.baihongyu.com/

你可能感兴趣的文章
20个Linux命令及Linux终端的趣事
查看>>
TSMessages,非HUD风格的iOS提示框(附官方demo BUG修复方案)
查看>>
我的友情链接
查看>>
Linux汇编GAS调用C语言函数实例
查看>>
linux-samba服务配置
查看>>
源码安装mysql5.6.20&&mysql主从设置(多实例做多个主从)
查看>>
ProgressDialog 简单使用记录
查看>>
docker centos7 容器上安装ssh
查看>>
DOS下远程共享磁盘
查看>>
从零开始的Spring Security Oauth2(一)
查看>>
Tomcat启动分析
查看>>
C++学习笔记(5):指针函数与函数指针
查看>>
Android 搭载Linux内核:三星放出源代码
查看>>
收藏链接地址,设为主页
查看>>
union union al l
查看>>
day-19:linux下打包tar工具及ZIP介绍
查看>>
lamp优化
查看>>
Bitshare2.0
查看>>
js实现继承方式
查看>>
单例模式 工厂模式
查看>>