/ Vijos / 讨论 / 问答 /

为什么评测机一跑这个程序就一直running?

p1374,是评测机的问题还是我的程序的问题?求鉴定。。

const

need:array[0..9] of longint

=(6,2,5,5,4,5,6,3,7,5);

type

ayy=array[1..30] of integer;

var

a,tmp:ayy;

ch:char;

n,base,sum,i,j,k:longint;

f:array[0..30,0..150] of boolean;

function check0(i:byte):boolean;

var

j:byte;

begin

for j:=1 to i do

begin

if tmp[j]>a[j] then

exit(false);

if tmp[j]a[j] then

exit(true);

if tmp[j]=need[j] then

begin

tmp[i]:=j;

dfs(i+1,now+need[j]);

tmp[i]:=0;

end;

end;

begin

readln(n);

sum:=0;

for i:=1 to n do

begin

read(ch);

a[i]:=ord(ch)-48;

sum:=sum+need[a[i]];

end;

fillchar(f,sizeof(f),false);

f[0,0]:=true;

for i:=1 to n do

for j:=1 to 110 do

for k:=0 to 9 do

if j>=need[k] then

if f[i-1,j-need[k]] then

f:=true;

fillchar(tmp,sizeof(tmp),0);

base:=0;

dfs(1,0);

base:=1;

dfs(1,0);

end.

1 条评论

  • 1