|
|
вернуться в форумCan someone help. please... I think my algorithm is right but... may be it is not!!! Here is my program. I used dynamic but got wrong answer...I don't know why???? If someone can give me some test... program The_time; var used : array[1..10000] of boolean; a:array[0..10000] of byte; st : array[1..50] of integer; n,k,i,j : integer; bool:boolean; Begin readln(n,k); for i:=1 to k do read(st[i]); a[0]:=1; for i:=1 to n do a[i]:=0; for i:=1 to n do Begin bool:=false; for j:=1 to k do if i>=st[j] then if a[i-st[j]]=2 then Begin a[i]:=1; break; End else if a[i-st[j]]=1 then if bool=false then bool:=true; if(bool)and(a[i]=0) then a[i]:=2; End; writeln(a[n]); End. A little change of your program program The_time; var used : array[1..10000] of boolean; a:array[0..10000] of byte; st : array[1..50] of integer; n,k,i,j : integer; bool:boolean; Begin readln(n,k); for i:=1 to k do read(st[i]); a[0]:=1; for i:=1 to n do a[i]:=0; for i:=1 to n do Begin bool:=false; for j:=1 to k do if i>=st[j] then if a[i-st[j]]=2 then Begin a[i]:=1; break; End; if a[i]=0 then a[i]:=2; {See here!} End; writeln(a[n]); End. Thanks...I got accepted!!!! > Thank you very much, i got accepted now!!!Although I can't find what was wrong with my program, but I'll will try to find. If I can help with something, just ask me... Re: A little change of your program Ok I got AC too. great! thanks! Not I d really love to know what difference that makes, for example how the hack could the first player win in that test case?.. Thank you very much! I got AC!!!!! ^_^ Послано Марина 17 май 2004 22:20 Thanks. :))) |
|
|