比赛 |
NOIP2008集训模拟3 |
评测结果 |
C |
题目名称 |
IP网络管理员 |
最终得分 |
0 |
用户昵称 |
chengyang |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-11-12 11:26:28 |
显示代码纯文本
program networkip;
var
ss:array[1..1001,1..4]of string;
n,m,code:longint;
ans1,ans2:string;
procedure shi(var kk:string);
var
x,k,j,code,i,q,l:longint;
y,cc,dd:string;
Begin
cc:='';
for k:=1 to 4 do begin
y:=copy(kk,1,8);
delete(kk,1,8);
q:=0;
for i:=1 to 8 do begin
x:=1;
for j:=8 downto i do x:=x*(ord(y[i])-48);
q:=q+x;
end;
l:=q div 10;
if l>=10 then l:=3
else if l<1 then l:=1
else l:=2;
str(q,l:0,dd);
cc:=cc+dd+'.';
end;
kk:=cc;
l:=length(kk);
delete(kk,l,1);
End;
procedure er(var l:string);
var
x,k,code:longint;
y:string;
Begin
val(l,k,code);
l:='';
while k>1 do begin
x:=k mod 2;
k:=k div 2;
y:=chr(x+48);
l:=y+l;
end;
y:=chr(k+48);
l:=y+l;
if length(l)<8 then
for k:=1 to (8-length(l)) do l:='0'+l;
End;
procedure ini;
var
i,k,j,code:integer;
s:string;
Begin
assign(input,'networkip.in');
assign(output,'networkip.out');
reset(input); rewrite(output);
readln(m);
for i:=1 to m do begin
readln(s);
for j:=1 to 3 do begin
k:=pos(s,'.');
ss[i,j]:=copy(s,1,k-1);
delete(s,1,k);
end;
ss[i,4]:=s;
for j:=1 to 4 do er(ss[i,j]);
end;
End;
procedure go;
var
s1,s2:string;
i,j,k:longint;
Begin
ans1:=''; ans2:='';
i:=1; j:=1; k:=1;
s1:='';
while (j<4)and(pos(s1,ss[k,j][i])=1) do begin
if i=8 then begin
j:=j+1;
k:=1; i:=1;
end;
if k=m then begin
s1:=ss[k,j][i];
k:=1; i:=i+1;
end;
k:=k+1;
end;
n:=32-(i+8*j);
j:=1; i:=1;
for k:=1 to 32-n do begin
ans1:=ans1+ss[1,j][i];
ans2:=ans2+'1';
if i=8 then begin
i:=1; j:=j+1
end;
i:=i+1;
end;
for k:=1 to n do begin
ans1:=ans1+'0';
ans2:=ans2+'0';
end;
shi(ans1);
shi(ans2);
End;
Begin
ini;
go;
writeln(ans1);
writeln(ans2);
close(input); close(output);
End.