|
|
вернуться в форумHelp me ,why WA #11 #include<stdio.h> int main() { _int64 f[2005]; int i,j,n,x,y,min,max; _int64 fi,fj,fmax,fmin; scanf("%d",&i); scanf("%lld",&fi); scanf("%d",&j); scanf("%lld",&fj); scanf("%d",&n);
int k; _int64 fib[2100]; fib[0]=0; fib[1]=1; fib[2]=1; for(k=3;k<2100;k++) { fib[k]=fib[k-2]+fib[k-1]; } f[i+1001]=fi; f[j+1001]=fj; if(i<j){min=i;max=j;fmax=fj;fmin=fi;} else {min=j; max=i; fmax=fi; fmin=fj;} x=min-2; y=max-x; f[min-1+1001]=(fmax-fib[y-1]*fmin)/fib[y-2]; for(i=min+1+1001;i<=1000+1001;i++) { f[i]=f[i-1]+f[i-2]; } for(i=0;i<=1000+1001;i++) { if(i==n+1001) { printf("%lld\n",f[i]);
} } return 0; } Re: Help me ,why WA #11 Послано Sunnat 7 янв 2012 14:01 Sizda tipdan kamchilik. ya'ni __int64 tipi fibanachi sonining (45 - 47 oraliqgacha) elementigacha hisoblay oladi xolos,undan ortig'i si'g'maydi. bundan tashqari fibanachi sonining 2000 - elementi 10^10450 xonali bo'ladi menda ham shu muammo Послано Sunnat 7 янв 2012 14:04 Sizda tipdan kamchilik. ya'ni __int64 tipi fibanachi sonining (45 - 47 oraliqgacha) elementigacha hisoblay oladi xolos,undan ortig'i si'g'maydi. bundan tashqari fibanachi sonining 2000 - elementi 10^10450 xonali bo'ladi Edited by author 07.01.2012 14:05 |
|
|