1003 - Sibonacci Numbers

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

时间: 2024-12-21 08:38:57

1003 - Sibonacci Numbers的相关文章

USTC OJ — 1003 Fibonacci Numbers(组合数学, 简单题)

1. 题目描述 Fibonacci数列定义为: A0 = 0, A1 = 1; An = An-1 + An-2, if n >= 2. 问题:输入一个n( 0 ≤ n ≤ 40 ),计算An. 2. 算法设计 直接利用公式计算即可,时间复杂度O(N),由于数据规模很小,可以选择 先打表,然后对每一个测试数据n,直接输出An: 或者分别对每一个n,计算An. 3. AC Code 1 #include <stdio.h> 2 #define N 41 3 int f[N]; 4 void

迪杰斯特拉算法——PAT 1003

本文主要是将我对于我对于迪杰斯特拉算法的理解写出来,同时通过例题来希望能够加深对于算法的理解,其中有错误的地方希望大家指正. 迪杰斯特拉算法 我将这个算法理解成一个局部到整体的算法,这个方法确实越研究就会发现越经典. 首先可以将整个图的节点看成两个集合:一个是S,一个是U-S.如果是求v0到图中各点的最短距离的话,那么S就是已经确认到v0距离最短的点,U-S则是对于整体的点集合U,还没有加入S集合的点. 这里提出一个算法总体的思想,将所有的点按照一定的原则加入到S集就是解集.而这个解法就是重点了

BestCoder Round #61 1001 Numbers

Problem Description There are n numbers A1,A2....An{A}_{1},{A}_{2}....{A}_{n}A?1??,A?2??....A?n??,your task is to check whether there exists there different positive integers i, j, k (1≤i,j,k≤n1\leq i , j , k \leq n1≤i,j,k≤n) such that Ai−Aj=Ak{A}_{i

HDU 1058 Humble Numbers(dp)

Problem Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, ... shows the first 20 humble numbers. Write a program to find and pri

CSUFT 1003 All Your Base

1003: All Your Base Time Limit: 1 Sec      Memory Limit: 128 MB Submit: 4      Solved: 2 Description Premise: Given a specification for a “base” (well, actually a mixed radix number system), take in pairs of numbers written in our “base”, perform a s

PAT (Advanced Level) Practise 1003 Emergency(SPFA+DFS)

1003. Emergency (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount

DP:Humble Numbers,丑数

描述A number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, ... shows the first 20 humble numbers.  Write a program to find and print the nth elemen

Acdream 1417 Numbers(暴力枚举)

传送门 Numbers Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) Submit Statistic Next Problem Problem Description Consider numbers from 1 to n. You have to find the smallest lexicographically number among them which is di

Bestcoder#5 1003

Bestcoder#5 1003 Poor RukawTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 24    Accepted Submission(s): 11 Problem Description Last time, Hanamichi lost the basketball battle between him and Ru