Cod sursa(job #124920)

Utilizator andreivFMI - vacaroiu andrei andreiv Data 20 ianuarie 2008 10:12:28
Problema Fructe Scor 100
Compilator fpc Status done
Runda preONI 2008, Runda 3, Clasele 5-8 Marime 0.57 kb
program de_mancat_fructe;
var  i,p,b,r:longint;

procedure mancare;
var i,j:longint;
begin
while b div 2<>0 do
begin
b:=b - 2;
p:=p+1;
end;
while p div 2<>0 do
p:=p-1;
if (p=1) and (b=0) then
r:=0 else
if (p=0) and (b=1) then
r:=1 else
if (p=1) and (b=1) then
r:=1;
end;


procedure citire;
var f,g:text;
    n:longint;
begin
assign(f,'fructe.in');
assign(g,'fructe.out');
reset(f);
rewrite(g);
read(f,n);
for i:=1 to n do
begin
readln(f);
read(f,p,b);
mancare;
write(g,r);writeln(g);
end;
close(f);
close(g);
end;


begin
citire;
end.