Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:RT.........(pascal) 求原因 以及改进方法

Posted by xiaobai1 at 2008-02-11 15:18:15 on Problem 3100
In Reply To:RT.........(pascal) 求原因 以及改进方法 Posted by:ysq1234 at 2007-02-01 00:47:33
> 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.


数组开小了,加多个0吧!!

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator