Cod sursa(job #2438511)

Utilizator RazvanucuPopan Razvan Calin Razvanucu Data 12 iulie 2019 17:19:42
Problema Trapez Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.63 kb
#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;
}