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:懂Pascal

Posted by ysq1234 at 2007-01-30 22:03:23 on Problem 1331
In Reply To:懂Pascal Posted by:ysq1234 at 2007-01-30 22:01:14
懂pascal的帮帮忙

Program ex;
Var
  what, i:Integer;
  q , p , r :Longint;
Procedure Try(i,j,k:LongInt);
Var
  sumi, max, sumj, sumk:Longint;
  a, b, c:Array[1..16] Of Word;
  s, t, pp, qq, rr:Integer;
Begin
  Fillchar(a,Sizeof(a),0);
  Fillchar(b,Sizeof(b),0);
  Fillchar(c,Sizeof(c),0);
  s:=0;
  pp:=0;
  Repeat
    Inc(pp);
    a[pp]:=i mod 10;
    If a[pp] > s Then s:=a[pp];
    i:=i div 10;
  Until i = 0;
  qq:=0;
  Repeat
    Inc(qq);
    b[qq]:=j mod 10;
    If b[qq] > s Then s:=b[qq];
    j:=j div 10;
  Until j = 0;
  rr:=0;
  Repeat
    Inc(rr);
    c[rr]:=k mod 10;
    If c[qq] > s Then s:=c[qq];
    k:=k div 10;
  Until k = 0;
  For t:=s+1 to 16 Do Begin
    sumi := 0;
    sumj := 0;
    sumk := 0;
    max:=1;
    For s:=1 to pp Do Begin
      sumi:=sumi + max * a[s];
      max:=max*t;
    End;
    max:=1;
    For s:=1 to qq Do Begin
      sumj:=sumj + max * b[s];
      max:=max*t;
    End;
    max:=1;
    For s:=1 to rr Do Begin
      sumk:=sumk + max * c[s];
      max:=max*t;
    End;
    If sumi*sumj=sumk Then Begin
      Writeln(t);
      Exit;
    End;
    If (t = 16) And (sumi*sumj<>sumk) Then Writeln('0');
  End;
End;
Begin
  Readln(what);
  For i:=1 to what Do Begin
    Readln(p,q,r);
    Try(p,q,r);
  End;
End.


程序写得比较乱,样例过得去,不知道拿错了(WA);我刚高一,学得不好,见谅

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