|
|
back to board#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; } Edited by author 10.04.2007 21:30 Edited by author 10.04.2007 21:31 Edited by author 10.04.2007 21:32 I've got WA#6 too Me too! I have no idea!I have submit 3 times I WA at test 6 !My Good! I have no idea!I have submit 3 times My AC code for input 10 170 gives 20035832260288179816689 Compare this to the max value of unsigned __int64: 18446744073709551615 Yeah, in this problem the answer can be bigger than int64. Use high precision instead, or Java. 我操!高精度? "我操!高精度?" What?! Edited by author 14.12.2011 12:24 Edited by author 14.12.2011 12:24 Edited by author 14.12.2011 12:24 "我操!高精度?" What?! Edited by author 14.12.2011 12:24 Edited by author 14.12.2011 12:24 Edited by author 14.12.2011 12:24 It means "F*CK! High precision?" It's not just High precision! Easy : 6 8 2 6 4 1 3 means 3146286 Hard : 286 146 3 means 3146286 |
|
|