比赛 |
NOIP2008集训模拟3 |
评测结果 |
AAAAAAAAAW |
题目名称 |
IP网络管理员 |
最终得分 |
90 |
用户昵称 |
MayLava |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-11-12 11:03:59 |
显示代码纯文本
program MayLava;
var
tcpip:array[1..1000,1..32]of integer;
minip,minmark:array[1..32]of integer;
m:longint;
procedure change(a,b,k:longint);
var
i,w:longint;
v:array[1..8]of integer;
begin
fillchar(v,sizeof(v),0);
w:=1;
while k>=2 do begin
v[w]:=k mod 2;
k:=k div 2;
inc(w);
end;
v[w]:=k;
for i:=1 to 8 do
tcpip[a,i+b*8]:=v[9-i];
end;
procedure start;
var
f:text;
snum,s:string;
i,j,num:longint;
begin
assign(f,'networkip.in');
reset(f);
readln(f,m);
for i:=1 to m do begin
readln(f,s);
for j:=0 to 2 do begin
snum:=copy(s,1,pos('.',s)-1);
delete(s,1,pos('.',s));
val(snum,num);
change(i,j,num);
end;
val(s,num);
change(i,3,num);
end;
close(f);
fillchar(minip,sizeof(minip),0);
fillchar(minmark,sizeof(minmark),0);
end;
procedure main;
var
i,j:longint;
flag:boolean;
begin
flag:=true;
i:=1;
while (i<=32) and flag do begin
flag:=true;
for j:=2 to m do
if tcpip[j,i]<>tcpip[j-1,i] then begin
flag:=false;
break;
end;
inc(i);
end;
if not(flag) then dec(i,2);
for j:=1 to i do begin
minip[j]:=tcpip[1,j];
minmark[j]:=1;
end;
end;
procedure print;
var
f:text;
i,j,temp:longint;
begin
assign(f,'networkip.out');
rewrite(f);
temp:=0;
for i:=0 to 3 do begin
for j:=8 downto 1 do
temp:=temp+round(minip[i*8+j]*exp(ln(2)*(8-j)));
write(f,temp);
if i<>3 then write(f,'.')
else writeln(f);
temp:=0;
end;
for i:=0 to 3 do begin
for j:=8 downto 1 do
temp:=temp+round(minmark[i*8+j]*exp(ln(2)*(8-j)));
write(f,temp);
if i<>3 then write(f,'.')
else writeln(f);
temp:=0;
end;
close(f);
end;
BEGIN
start;
main;
print;
END.