|
|
вернуться в форумWA #4!Please help1 Послано AKKAA 28 мар 2007 22:08 I don't understand why WA#4 here is my code(maybe I use uncorrect algo?): #include<iostream> #include<cmath> #include<stdio.h> using namespace std; int main() { unsigned __int64 k=0; long r; cin>>r; if(r==1) { cout<<4<<endl; return 0; } if(r==2) { cout<<16<<endl; return 0; } k=(r-1)*8; k=k+(r-1+r-1)*(r-1+r-1); printf("%I64u\n",k); return 0; } Re: WA #4!Please help1 Wrong algo :] For example: r = 5 correct_answer = 88 Your formula: a = 8*(5-1) = 8*4 = 32 b = (r-1+r-1)*(r-1+r-1) = (2r-2)^2 = 8^2 = 64 res = a+b = 32 + 64 = 96 correct_answer != res -> Wrong algo :] Edited by author 12.06.2009 01:14 |
|
|