ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1087. The Time to Take Stones

Give me some good test, please! I gov WA!
Posted by Algorithmus_UA(algorithmus@univ.kiev.ua) 15 Jun 2002 17:14
const MAXN  =  10000;
var N,M,i,j,min:integer;
    K:array[1..100]of integer;
    a:array[1..MAXN]of byte;
begin
  readln(N,M);
  for i:=1 to M do
  begin
     read(K[i]);
  end;
  for i:=1 to N do a[i]:=2;
  min:=MaxInt;
  for i:=1 to M do if min >  k[i] then min:=k[i];
  a[min]:=0;
  for i:=min+1 to N do
  begin
    for j:=1 to M do if (i-K[j]>0)and(a[i-K[j]]<>2) then
    begin
      if a[i-K[j]] = 0 then
      begin
         a[i]:=1;
         break;
      end else a[i]:=0;
    end;
  end;
  if a[N] = 0 then writeln(2)
  else writeln(1);
end.
A test for you(+)
Posted by shitty.Mishka 15 Jun 2002 18:39
Try this test:
117 2
15 17
Correct answer is 1
Thank's you vety much! Now I got AC!
Posted by Algorithmus_UA(algorithmus@univ.kiev.ua) 17 Jun 2002 14:12
Re: A test for you(+)
Posted by Yunzhong 1 Aug 2002 12:36
> Try this test:
> 117 2
> 15 17
> Correct answer is 1

But, 117 = 15*1+17*6;
so the first person will take four times and the second one three
times. This implies that the first one must be taking the last stone.