stone_2.pas 766 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. Program Stone_Algorithm2;
  2. Const
  3. inf='stone.in';
  4. outf='stone.out';
  5. maxn=1000000;
  6. Var
  7. a,b,ans:longint;
  8. f:array[0..maxn]of boolean;
  9. procedure swap;
  10. var t:longint;
  11. begin
  12. t:=a; a:=b; b:=t;
  13. end;
  14. procedure work;
  15. var i,t:longint;
  16. begin
  17. fillchar(f,sizeof(f),0);
  18. t:=0;
  19. for i:=0 to a-1 do
  20. if not f[i] then begin
  21. f[i+t]:=true;
  22. inc(t);
  23. end;
  24. if not(f[a]) and (a+t=b)
  25. then writeln(0) else writeln(1);
  26. end;
  27. Begin
  28. assign(input,inf); reset(input);
  29. assign(output,outf); rewrite(output);
  30. while not(seekeof) do
  31. begin
  32. read(a,b);
  33. if a>b then swap;
  34. work;
  35. end;
  36. close(input); close(output);
  37. End.