- 学姐的幸运数字
- 2014-11-28 15:48:38 @
var e,a:array[0..1000]of qword;
i,j,k,n,t:longint; ans:qword;
procedure try(x,l:qword);
var i,j,k:longint;
begin
if x>n then
begin
if (l<ans) then ans:=l;
exit;
end;
try(x+1,l and a[x]);
try(x+1,l xor a[x]);
try(x+1,l or a[x]);
try(x+1,l and not(a[x]));
try(x+1,l xor not(a[x]));
try(x+1,l or not(a[x]));
end;
begin
readln(t);
for i:=1 to t do
begin
readln(n);
if n>7 then writeln('Case #',i,': 0')
else
begin
for j:=1 to n do read(a[j]);
ans:=18446744073709551615;
try(2,a[1]);
try(2,not a[1]);
writeln('Case #',i,': ',ans);
end;
end;
end.
1 条评论
-
jixinye139 LV 10 @ 2014-11-28 15:49:46
var e,a:array[0..1000]of qword;
i,j,k,n,t:longint; ans:qword;procedure try(x,l:qword);
var i,j,k:longint;
begin
if x>n then
begin
if (l<ans) then ans:=l;
exit;
end;
try(x+1,l and a[x]);
try(x+1,l xor a[x]);
try(x+1,l or a[x]);
try(x+1,l and not(a[x]));
try(x+1,l xor not(a[x]));
try(x+1,l or not(a[x]));
end;
begin
readln(t);
for i:=1 to t do
begin
readln(n);
if n>7 then writeln('Case #',i,': 0')
else
begin
for j:=1 to n do read(a[j]);
ans:=18446744073709551615;
try(2,a[1]);
try(2,not a[1]);
writeln('Case #',i,': ',ans);
end;
end;
end.
- 1
信息
- ID
- 1904
- 难度
- 7
- 分类
- (无)
- 标签
- (无)
- 递交数
- 421
- 已通过
- 82
- 通过率
- 19%
- 被复制
- 4
- 上传者