Pagini recente » Cod sursa (job #2487947) | Cod sursa (job #2830658) | Cod sursa (job #995712) | Cod sursa (job #1456587) | Cod sursa (job #1542230)
#include <fstream>
using namespace std;
ifstream fin("fructe.in");
ofstream fout("fructe.out");
bool whichFruct(int p, int b) {
if (p >= 1 and b >= 1)
--p;
else if (p >= 2)
--p;
else if (b >= 2) {
b -= 2;
++p;
}
if (p == 1 and b == 0)
return 0;
if (p == 0 and b == 1)
return 1;
return whichFruct(p, b);
}
int main()
{
int t;
fin >> t;
for (int i = 1; i <= t; ++i) {
int p, b;
fin >> p >> b;
fout << whichFruct(p, b) << "\n";
}
return 0;
}