Cod sursa(job #124991)
Utilizator | Vlad Radu - Cristian nightwish | Data | 20 ianuarie 2008 10:51:02 |
---|---|---|---|
Problema | Fructe | Scor | 100 |
Compilator | cpp | Status | done |
Runda | preONI 2008, Runda 3, Clasele 5-8 | Marime | 0.46 kb |
#include<stdio.h>
int main()
{
int t,i;
long p,b;
freopen("fructe.in","r",stdin);
freopen("fructe.out","w",stdout);
scanf("%d ",&t);
for (i=1;i<=t;i++)
{
scanf("%ld%ld",&p,&b);
while(1)
{
if (p>1) p--;
else
if (b>1) {b-=2;p++;}
else
if (p==1){p--;}
else
if (b==1){p--;}
if ((p==1&&b<=0)||(p<=0&&b==1))
break;
}
if (p) printf("0\n");
else printf("1\n");
}
return 0;
}