比赛 |
NOIP2008集训模拟3 |
评测结果 |
EEEEEEEEEE |
题目名称 |
IP网络管理员 |
最终得分 |
0 |
用户昵称 |
zxc111 |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-11-12 10:28:33 |
显示代码纯文本
program ooo;
var
i,j,k,n,m:longint;
s:string;
max,min:string;
t:text;
se:array[1..20] of string;
a,b,c:array[1..32] of longint;
procedure oo(s:string;ss:longint);
var
i,j,k,n:longint;
d:array[1..32] of longint;
begin
val(s,n,k);
i:=0;
fillchar(d,sizeof(d),0);
while n<>0 do
begin
inc(i);
d[i]:=n mod 2;
n:=n div 2;
end;
for i:=8 downto 1 do
a[ss*8+8-i+1]:=d[i];
end;
begin
assign(t,'networkip.in');
reset(t);
readln(t,n);
min:='255.255.255.255';
max:='0.0.0.0';
for i:=1 to n do
begin
readln(t,s);
if s>max then max:=s;
if s<min then min:=s;
end;
close(t);
j:=1;
k:=0;
m:=-1;
min:=min+'.';
max:=max+'.';
n:=0;
for i:=1 to length(min) do
if min[i]='.' then begin k:=i-1;s:=copy(min,j,n);inc(m);oo(s,m);j:=i+1;n:=0;end else inc(n);
for i:=1 to 32 do
b[i]:=a[i];
j:=1;
k:=0;
m:=-1;
n:=0;
for i:=1 to length(max) do
if max[i]='.' then begin k:=i-1;s:=copy(max,j,n);inc(m);oo(s,m);j:=i+1;n:=0;end else inc(n);
for i:=1 to 32 do
c[i]:=a[i];
i:=1;
while b[i]=c[i] do
inc(i);
dec(i);
fillchar(a,sizeof(a),0);
for j:=1 to i do
a[j]:=b[j];m:=i;
n:=0;
assign(t,'networkip.in');
rewrite(t);
for i:=1 to 32 do
begin
if i mod 8=0 then begin write(t,n+a[i]);n:=0;end else if a[i]=1 then
n:=n+trunc(exp((8-(i mod 8))*ln(2)));
if i=8 then write(t,'.');
if i=16 then write(t,'.');
if i=24 then write(t,'.');
end;
n:=0;
writeln(t);
fillchar(a,sizeof(a),0);
for i:=1 to m do
a[i]:=1;
for i:=1 to 32 do
begin
if (i mod 8=0) then begin write(t,n+a[i]);n:=0;end else if a[i]=1 then
n:=n+trunc(exp((8-(i mod 8))*ln(2)));
if i=8 then write(t,'.');
if i=16 then write(t,'.');
if i=24 then write(t,'.');
end;
close(t);
end.