| ||||||||||
| 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 | |||||||||
Help.................const
w2:array [1..3] of integer=(9,3,7);
q=20;
var
a,b:array [1..q] of integer;
n,i,j,k,l:integer;
max:longint;
s:string;
begin
assign(input,'a2498.in');
reset(input);
readln(n);
for i:=1 to n do
begin
fillchar(a,sizeof(a),0);
fillchar(b,sizeof(b),0);
readln(s);l:=length(s);k:=1;max:=0;
writeln('Scenario #',i,':');
for j:=1 to l do
if s[j]='?' then a[q-l+j]:=0
else a[q-l+j]:=ord(s[j])-48;
for j:=q downto q-l+1 do
begin
b[j]:=w2[k];k:=(k+1) mod 3;
if k=0 then k:=3;
max:=max+a[j]*b[j];
end;
k:=pos('?',s);
if (k=3) or (k=7) then
begin
for j:=1 to 10 do
if (max+j*b[q-l+k]) mod 10=0 then
begin a[q-l+k]:=j;break;end;
end
else
begin
for j:=1 to 9 do
if (max+j*b[q-l+k]) mod 10=0 then
begin a[q-l+k]:=j;break;end;
end;
for j:=q-l+1 to q do write(a[j]);writeln;
if i<>n then writeln;
end;
close(input);
end.
大牛们看看,这个程序为什么会runtime error?谢谢!
(there's always exactly one correct digit, thanks to 9, 3 and 7 being relatively prime to 10).
还有这一句话什么意思的撒!本人英语不太好!毕竟才初一啊!谢谢
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator