记录编号 |
7990 |
评测结果 |
AAAAAAAAAA |
题目名称 |
IP网络管理员 |
最终得分 |
100 |
用户昵称 |
rottenwood |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.083 s |
提交时间 |
2008-11-12 17:06:31 |
内存使用 |
0.13 MiB |
显示代码纯文本
program networkip;
type
shuzu=array[1..1000,1..4] of longint;
shuzu1=array[1..2,1..4]of longint;
var
f:shuzu;
s:shuzu1;
i,j,k,n,m,x,y,x1,y1,temp,temp1,num,min,code:longint;
s1,s2,s3,s4,s5,s6:string;
function zh(x:longint):string;
var
i,j,k:longint;
s7,s8:string;
begin
s7:='';s8:='';
while x<>0 do
begin
k:=x mod 2;
str(k,s7);
s8:=s7+s8;
x:=x div 2;
end;
if length(s8)<8 then
while length(s8)<>8 do
s8:='0'+s8;
zh:=s8;
end;
procedure zhuanhuan(x:string);
var
i,j,k,ans:longint;
a:array[1..8] of integer;
begin
for i:=1 to 8 do
a[i]:=ord(x[i])-48;
m:=a[8];
ans:=1;
for i:=7 downto 1 do begin
ans:=ans*2;
m:=m+ans*a[i];
end;
end;
begin
assign(input,'networkip.in');reset(input);
assign(output,'networkip.out');rewrite(output);
readln(n);
for i:=1 to n do
begin
readln(s1);
j:=1;
for k:=1 to 3 do
begin
s2:=copy(s1,1,pos('.',s1)-1);
delete(s1,1,pos('.',s1));
val(s2,f[i,j],code);
inc(j);
end;
val(s1,f[i,4],code);
end;
for i:=1 to n-1 do
for j:=i+1 to n do
if (f[i,1]>f[j,1])
or(f[i,1]=f[j,1])and(f[i,2]>f[j,2])
or(f[i,1]=f[j,1])and(f[i,2]=f[j,2])and(f[i,3]>f[j,3])
or(f[i,1]=f[j,1])and(f[i,2]=f[j,2])and(f[i,3]=f[j,3])and(f[i,4]>f[j,4])
then begin
x:=f[i,1]; y:=f[i,2]; x1:=f[i,3]; y1:=f[i,4];
f[i,1]:=f[j,1]; f[i,2]:=f[j,2]; f[i,3]:=f[j,3];f[i,4]:=f[j,4];
f[j,1]:=x; f[j,2]:=y; f[j,3]:=x1; f[j,4]:=y1;
end;
for i:=1 to 4 do
s3:=s3+zh(f[1,i]);
for i:=1 to 4 do
s4:=s4+zh(f[n,i]);
for i:=1 to 32 do
if s3[i]<>s4[i] then break;
if i<32 then begin
s5:=copy(s3,1,i-1);
for j:=i to 32 do
s5:=s5+'0';
for j:=1 to i-1 do
s6:=s6+'1';
for j:=i to 32 do
s6:=s6+'0';
end
else begin
s5:=copy(s3,1,i);
for j:=1 to 32 do
s6:=s6+'1';
end;
//////////////////////////////////////////////////////////////////////////
for i:=1 to 4 do
begin
s2:=copy(s5,1,8);
delete(s5,1,8);
zhuanhuan(s2);
s[1,i]:=m;
end;
for i:=1 to 4 do
begin
s2:=copy(s6,1,8);
delete(s6,1,8);
zhuanhuan(s2);
s[2,i]:=m;
end;
for i:=1 to 3 do
begin
write(s[1,i]);
write('.');
end;
writeln(s[1,4]);
for i:=1 to 3 do
begin
write(s[2,i]);
write('.');
end;
writeln(s[2,4]);
close(output);
end.