| ||||||||||
| 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 | |||||||||
哪错了?这道题要把我弄疯了,我的程序过了所有我看见的数据,但还是WA,下面是我的代码,哪位大牛帮看一下,我的邮箱是756598772@qq.com,也可以在下面回复,万分感谢!
program wjy;
var
n,i,num,tail,mo,wei,j,k:longint;
s:char;
f:array[0..10000000]of integer;
ans:array[0..100000]of longint;
function ys(a:char):integer;
begin
if (ord(a)>=ord('0')) and (ord(a)<=ord('9')) then exit(ord(a)-ord('0'));
case a of
'A','B','C':exit(2);
'D','E','F':exit(3);
'G','H','I':exit(4);
'J','K','L':exit(5);
'M','N','O':exit(6);
'P','S','R':exit(7);
'T','U','V':exit(8);
else exit(9);
end;
end;
procedure qksort(p,q:longint);
var a,b,com,mid:longint;
begin
com:=ans[(p+q) div 2];
a:=p;b:=q;
repeat
while ans[a]<com do inc(a);
while ans[b]>com do dec(b);
if a<b then begin mid:=ans[a];ans[a]:=ans[b];ans[b]:=mid; end;
inc(a);dec(b);
until a>b;
if a<q then qksort(a,q);
if b>p then qksort(p,b);
end;
begin
readln(n);
tail:=0;
fillchar(f,sizeof(f),0);
fillchar(ans,sizeof(ans),127);
for i:=1 to n do
begin
num:=0;
while not eoln do
begin
read(s);
if (s<>'-') then
begin
num:=10*num+ys(s);
end;
end;
readln;
inc(f[num]);
if f[num]=2 then
begin
inc(tail);
ans[tail]:=num;
end;
end;
qksort(1,tail);
if tail=0 then writeln('No duplicates.')
else begin
for i:=1 to tail do
begin
wei:=1;mo:=1000000;
num:=ans[i];
while wei<=3 do
begin
inc(wei);
write(num div mo);
num:=num-(num div mo)*mo;
mo:=mo div 10;
end;
write('-');
while wei<=7 do
begin
inc(wei);
write(num div mo);
num:=num-num div mo*mo;
mo:=mo div 10;
end;
writeln(' ',f[ans[i]]);
end;
end;
end.
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator