ACM的一道题,看着很简单,提交却WA了,More than FibonacciTime Limit:1000msMemory Limit:65536kbDescriptionThe New Fibonacci numbers (0,1,2,3,6,11,20,37,68,...) are defined by the recurrence:F(0) = 0; F(1) = 1; F(2) = 2; F(n) = F(n-1) + F(n-2)
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/18 20:35:12
ACM的一道题,看着很简单,提交却WA了,More than FibonacciTime Limit:1000msMemory Limit:65536kbDescriptionThe New Fibonacci numbers (0,1,2,3,6,11,20,37,68,...) are defined by the recurrence:F(0) = 0; F(1) = 1; F(2) = 2; F(n) = F(n-1) + F(n-2)
ACM的一道题,看着很简单,提交却WA了,
More than Fibonacci
Time Limit:1000ms
Memory Limit:65536kb
Description
The New Fibonacci numbers (0,1,2,3,6,11,20,37,68,...) are defined by the recurrence:F(0) = 0; F(1) = 1; F(2) = 2;
F(n) = F(n-1) + F(n-2) + F(n-3) for all n>2
Write a program to calculate the New Fibonacci numbers.
Input
The input is a sequence of integers not more than 36,each on a separate line,specifying which New Fibonacci number to calculate.
Output
Print the New Fibonacci numbers in the format shown in Sample Output.
Sample Input
5
7
11
Sample Output
The New Fibonacci number for 5 is 11
The New Fibonacci number for 7 is 37
The New Fibonacci number for 11 is 423
我的代码:
#include
main()
{
\x05long F[37];
\x05int i,n;
\x05while(scanf("%d",&n)!=EOF)
\x05{
\x05\x05F[0]=0;F[1]=1;F[2]=2;
\x05\x05for(i=3;i
ACM的一道题,看着很简单,提交却WA了,More than FibonacciTime Limit:1000msMemory Limit:65536kbDescriptionThe New Fibonacci numbers (0,1,2,3,6,11,20,37,68,...) are defined by the recurrence:F(0) = 0; F(1) = 1; F(2) = 2; F(n) = F(n-1) + F(n-2)
#include
int main()
{
long F[37];
int i,n;
F[0]=0;F[1]=1;F[2]=2;
for(i=3;i