记录编号 |
7954 |
评测结果 |
AAAAAAAAAA |
题目名称 |
IP网络管理员 |
最终得分 |
100 |
用户昵称 |
EnAsn |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.029 s |
提交时间 |
2008-11-12 16:01:18 |
内存使用 |
0.11 MiB |
显示代码纯文本
program ex;
type
ss=array[1..4]of integer;
sz=array[0..32]of integer;
zs=array[1..8]of integer;
var
a:ss;
f,b,c:sz;
jz:zs;
f1,f2:text;
m:integer;
procedure zhh(a:ss;var b:sz);
var
i,j:integer;
begin
fillchar(b,sizeof(b),0);
b[0]:=32;
for i:=1 to 4 do
for j:=(8*i) downto (8*(i-1)+1) do
begin
b[j]:=a[i] mod 2;
a[i]:=a[i] div 2;
end;
end;
procedure comper(b:sz;var c:sz);
var
i,t:integer;
begin
t:=0;
for i:=1 to b[0] do
if b[i]=c[i] then inc(t)
else break;
b[0]:=t;
if b[0]<c[0] then c[0]:=b[0];
end;
procedure init;
var
i,j,code:integer;
s,s1:string;
l1,l2:integer;
begin
jz[1]:=1;jz[2]:=2;jz[3]:=4;jz[4]:=8;
jz[5]:=16;jz[6]:=32;jz[7]:=64;jz[8]:=128;
assign(f1,'networkip.in');
assign(f2,'networkip.out');
reset(f1);
rewrite(f2);
readln(f1,m);
for i:=1 to m do
begin
readln(f1,s);
for j:=1 to 3 do
begin
l2:=pos('.',s);
s1:=copy(s,1,l2-1);
val(s1,a[j],code);
delete(s,1,l2);
end;
val(s,a[j+1],code);
for j:=1 to 4 do
begin
zhh(a,b);
if i>1 then comper(b,c)
else begin
c:=b;
c[0]:=b[0];
end;
end;
end;
close(f1);
end;
procedure main;
var
i,j,t,k:integer;
begin
for i:=1 to c[0] do
f[i]:=1;
for i:=c[0]+1 to 32 do
begin
f[i]:=0;
c[i]:=0;
end;
for i:=1 to 4 do
begin
t:=0;k:=0;
for j:=i*8 downto (8*(i-1)+1) do
begin
inc(k);
t:=t+c[j]*jz[k];
end;
if i<4 then write(f2,t,'.')
else writeln(f2,t);
end;
for i:=1 to 4 do
begin
t:=0;k:=0;
for j:=i*8 downto (8*(i-1)+1) do
begin
inc(k);
t:=t+f[j]*jz[k];
end;
if i<4 then write(f2,t,'.')
else writeln(f2,t);
end;
end;
begin
init;
main;
close(f2);
end.