|
|
back to boardWHY WA#6?HERE IS MY CODE!!THANK!!!! #include<iostream.h> #include<stdio.h> int main() { int n,i,k;unsigned __int64 a[2000],p; cin>>n>>k;a[1]=k-1;a[2]=k*(k-1); for(i=3;i<=n;i++) {a[i]=(k-1)*(a[i-1]+a[i-2]);p=a[i];} if(n==1) cout<<k-1; else if(n==2) cout<<k*(k-1); else if(n>=3) printf("%I64u", p); return 0; } Re: WHY WA#6?HERE IS MY CODE!!THANK!!!! You should use long arithmetic!!! Re: WHY WA#6?HERE IS MY CODE!!THANK!!!! CAN I SOLVE IT WHITOUT LONG ARITHMETIC?THANK!!! Yes:) 1)hacking ;) - bad way 2)find answers for all test cases but more easy to write LA Edited by author 11.04.2007 18:10 Re: WHY WA#6?HERE IS MY CODE!!THANK!!!! I have the solution!!! do you want Re: WHY WA#6?HERE IS MY CODE!!THANK!!!! THANK ALL OF YOU!!! |
|
|