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 |
为什么我的程序WA了???大家帮忙看看program p2100; var n,mid:qword; t,w,i,j,k,s,m,p:longint; tt:boolean; ans:double; a:array[1..1000000,1..2] of longint; begin read(n); m:=trunc(sqrt(n)); p:=trunc(exp(ln(n)/3))div 2+1000; for i:=p downto 1 do begin tt:=false; t:=0;w:=m; while t<=w do begin mid:=(t+w) div 2; ans:=(mid+i)*(mid+i+1)*((mid+i)*2+1)/6-mid*(mid+1)*(mid*2+1)/6; if abs(ans-n)<=0.01 then begin tt:=true;break;end; if ans>n then if mid=0 then break else w:=mid-1 else t:=mid+1; end; if tt then begin s:=s+1; a[s,1]:=i;a[s,2]:=mid; end; end; writeln(s); for i:=1 to s do begin write(a[i,1]); for j:=1 to a[i,1] do write(' ',a[i,2]+j); writeln; end; end. end. Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator