Pagini recente » Cod sursa (job #2353406) | Cod sursa (job #883780) | Cod sursa (job #74456) | Cod sursa (job #908233) | Cod sursa (job #2438511)
#include <bits/stdc++.h>
using namespace std;
ifstream f("pietre.in");
ofstream g("pietre.out");
int i,t,A,B,pereche;
int caz_castiga2[1000001];
int main()
{
caz_castiga2[1]=2;
caz_castiga2[2]=1;
pereche=2;
for(i=3; i<1000001; i++)
if(caz_castiga2[i]==0)
{
caz_castiga2[i]=i+pereche;
if(i+pereche<1000001)
caz_castiga2[i+pereche]=i;
pereche++;
}
f>>t;
for(i=0; i<t; i++)
{
f>>A>>B;
if(caz_castiga2[A]==B)
g<<"2\n";
else
g<<"1\n";
}
return 0;
}