[Login|Register]
New post

Show post

Search forum

Read post
求教WA的原因 [ Topic ] 2011-04-11 16:52:41 hscwz
#include<stdio.h>

int main()
{
long long a[100],i=1,n[100],max=0,j;
    while(scanf("%lld",&n[i])!=EOF)
    {    if(n[i]>max)  max=n[i];
        i++;
    }
    a[0]=0;a[1]=1;a[2]=2;

    for(j=3;j<=max;j++)
    {
        a[j]=a[j-3]+a[j-2]+a[j-1];
    }
    for(j=1;j<=i-1;j++)
    {
        printf("The Fibonacci number for %lld is %lld\n",n[j],a[n[j]]);
    }
    return 0;
}


Reply
Title
Message
(64K)
University of Science and Technology of China
Online Judge for ACM/ICPC
Processed in 1.7ms with 2 query(s).