Cod sursa(job #125036)
Utilizator | Maria Mateescu matemariaescu | Data | 20 ianuarie 2008 11:05:25 |
---|---|---|---|
Problema | Fructe | Scor | 100 |
Compilator | fpc | Status | done |
Runda | preONI 2008, Runda 3, Clasele 5-8 | Marime | 0.75 kb |
program magic_tree;
var t, i : longint;
p,b : longint;
fin,fout:text;
begin
assign(fin,'fructe.in'); reset(fin);
assign(fout,'fructe.out'); rewrite(fout);
readln(fin, t);
for i := 1 to t do
begin
readln(fin,p,b);
while p+b > 1 do
begin
if (p>0) and (b>0) then
begin
p:=p-1;
end
else if (p>0) and (b=0) then
begin
p:=p-1;
end
else if (b>0) and (p=0) then
begin
b:=b-2;
p:=p+1;
end;
end;
if p = 1 then
writeln (fout,0)
else writeln(fout,1);
end;
close(fout);
close(fin);
end.