比赛 NOIP2008集训模拟3 评测结果 WWWWWWWWWW
题目名称 IP网络管理员 最终得分 0
用户昵称 打不死的羊 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-11-12 09:18:12
显示代码纯文本
program networkip;
type
fxz1=array[1..4] of integer;
var
f1,f2:text;
max,min,a:fxz1;
s:string;
n,k,i:longint;
procedure zh(s:string;var a:fxz1);
var
code,m,i:integer;
ss:string;
begin
for i:=1 to 3 do
begin
m:=pos('.',s);
ss:=copy(s,1,m-1);
delete(s,1,m);
val(ss,a[i],code);
end;
val(s,a[4],code);
end;
{...................................}
procedure pan(a:fxz1);
var
f:boolean;
i:longint;
begin
f:=true;
for i:=1 to 4 do
if a[i]<max[i] then begin f:=false;break;end;
if f then max:=a;
f:=true;
for i:=1 to 4 do
if a[i]>min[i] then begin f:=false;break;end;
if f then min:=a;
end;
{.....................................}
procedure ans1;
var
i:longint;
begin
i:=4;
dec(min[i]);
while min[i]<0 do
begin
min[i]:=0;
if i<>1 then begin dec(i);dec(min[i]);end;
end;
for i:=1 to 3 do
write(f2,min[i],'.');
writeln(f2,min[4]);
end;
{.....................................}
procedure ans2;
var
i:longint;
 procedure jian(max,min:fxz1;var a:fxz1);
 var
 i:longint;
 begin
 for i:=1 to 4 do a[i]:=max[i]-min[i];
 for i:=4 downto 2 do if a[i]<0 then begin a[i]:=256+a[i];
                                           dec(a[i-1]);
                                     end;
 end;
begin
jian(max,min,a);
for i:=1 to 4 do max[i]:=255;
jian(max,a,min);
for i:=1 to 3 do
write(f2,min[i],'.');
writeln(f2,min[4]);
end;
{......................................................}
begin
assign(f1,'networkip.in');
assign(f2,'networkip.out');
reset(f1);rewrite(f2);
readln(f1,n);
for i:=1 to 4 do begin max[i]:=0;min[i]:=255;end;
for i:=1 to n do
begin
readln(f1,s);
zh(s,a);
pan(a);
end;
ans1;
ans2;
close(f1);close(f2);
end.