测评机: Xeost[5]
得分: 100分
提交日期: 2010-9-27 22:10:00
有效耗时: 6141毫秒
测试结果1: 通过本测试点|有效耗时313ms
测试结果2: 通过本测试点|有效耗时359ms
测试结果3: 通过本测试点|有效耗时531ms
测试结果4: 通过本测试点|有效耗时688ms
测试结果5: 通过本测试点|有效耗时390ms
测试结果6: 通过本测试点|有效耗时610ms
测试结果7: 通过本测试点|有效耗时875ms
测试结果8: 通过本测试点|有效耗时609ms
测试结果9: 通过本测试点|有效耗时844ms
测试结果10: 通过本测试点|有效耗时922ms
提交代码: view sourceprint?01.Program t178;
02.
Var a,b:array [1..900] of longint;
03.
i,j,w,n,ans:longint;
04.
Function zh(x:longint):int64;
05.
Var s,s1:string;
06.
i:longint;
07.
Begin
08.
s:='';
09.
While x<>0 do begin
10.
s:=s+chr(48+x mod 7);
11.
x:=x div 7;
12.
end;
13.
s1:='';
14.
For i:=length(s) downto 1 do s1:=s1+s[i];
15.
val(s1,zh);
16.
end;
17.
Function hb(x1,x2:int64):longint;
18.
Var s1,s2,s3:string;
19.
i,max,len1,len2:longint;
20.
Begin
21.
str(x1,s1); str(x2,s2);
22.
len1:=length(s1); len2:=length(s2);
23.
s3:='';
24.
if len1>len2 then max:=len1 else max:=len2;
25.
For i:=1 to max-len1 do s3:=s3+'0';
26.
s3:=s3+s1; s1:=s3;s3:='';
27.
For i:=1 to max-len2 do s3:=s3+'0';
28.
s3:=s3+s2; s2:=s3; s3:='';
29.
For i:=1 to max do
30.
if s1[i]=s2[i] then s3:=s3+'0'
31.
else s3:=s3+'1';
32.
hb:=0;
33.
For i:=length(s3) downto 1 do
34.
hb:=hb+(ord(s3[i])-48)*trunc(round(exp((length(s3)-i)*ln(2))));
35.
end;
36.
Begin
37.
readln(n);
38.
For i:=1 to n do begin
39.
read(a[i]); b[i]:=zh(a[i]);
40.
end;
41.
ans:=10000;
42.
For i:=1 to n-1 do
43.
For j:=i+1 to n do begin
44.
w:=hb(b[i],b[j]);
45.
if abs(w-123)<abs(ans-123) then ans:=w;
46.
end;
47.
Writeln(ans);
48.
end.