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 |
RT.........(pascal) 求原因 以及改进方法Program ex; Var ss:Array[1..10000] Of LongInt; a, tt, sss, s, s1, s2, s3:Longint; b, t, i, j:Integer; Begin Readln(a,b); Repeat Fillchar(ss, sizeof(ss), 0); If b = 1 Then Writeln(a) Else Begin If b = 2 Then Begin s:=trunc(sqrt(a)); s1:=(s-1)*(s-1); s2:=s*s; s3:=(s+1)*(s+1); If a-s1>abs(s2-a) Then Begin sss:=s; tt:=abs(s2-a); End Else Begin sss:=s-1; tt:=a-s1; End; If s3-a<tt Then Begin tt:=s3-a; sss:=s+1; End; Writeln(sss); End Else Begin i:=0; Repeat Inc(i); s:=1; For j:=1 to b Do s := s * i; ss[i]:=s; Until s >= a; If ss[i] + ss[i - 1] > 2 * a Then Writeln(i - 1) Else Writeln(i); End; End; Readln(a,b); Until (a = 0) And (b = 0); End. Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator