Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:这题用不着哈希吧!二分+暴力,直接开个100W数组记录,加上qsort。In Reply To:这题用不着哈希吧!二分+暴力,直接开个100W数组记录,加上qsort。 Posted by:lydliyudong at 2011-06-17 17:53:39 我表示我连二分都没有...裸暴力,时间是你的三分之一800+ms...难道是人品问题...? var a:array[1..5]of longint; f:array[-12500000..12500000]of integer; ans,i,j,k,tmp:longint; function pow(x:longint):longint; begin exit(x*x*x); end; begin for i:=1 to 5 do read(a[i]); for i:=-50 to 50 do for j:=-50 to 50 do for k:=-50 to 50 do if (i<>0)and(j<>0)and(k<>0) then begin tmp:=0; inc(tmp,a[1]*pow(i)); inc(tmp,a[2]*pow(j)); inc(tmp,a[3]*pow(k)); if abs(tmp)<=12500000 then inc(f[tmp]); end; for i:=-50 to 50 do for j:=-50 to 50 do if (i<>0)and(j<>0) then begin tmp:=0; inc(tmp,a[4]*pow(i)); inc(tmp,a[5]*pow(j)); inc(ans,f[-tmp]); end; writeln(ans); end. Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator