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

顶起PASCAL!

Posted by 875319120 at 2012-08-27 15:11:38 on Problem 2498
var
  n,i,j,len,he,k,m:longint;
  a:string;
begin
  readln(n);
  for i:=1 to n do
    begin
      he:=0;
      readln(a);
      writeln('Scenario #',i,':');
      len:=length(a);
      for j:=len downto 1 do
        if a[j]<>'?' then begin
           if (len-j+1)mod 3=1 then k:=9
           else if (len-j+1)mod 3=2 then k:=3
           else k:=7;
           he:=he+(ord(a[j])-48)*k;
           end;
      m:=pos('?',a);
      if (len-m+1)mod 3=1 then k:=9
      else if (len-m+1)mod 3=2 then k:=3
      else k:=7;
      for j:=0 to 9 do
      begin
        he:=he+j*k;
        if he mod 10=0 then begin a[m]:=chr(j+48); break; end else he:=he-j*k;
      end;
      writeln(a);
      writeln;
  end;
end.

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