Cod sursa(job #1709239)

Utilizator iulianrotaruRotaru Gheorghe-Iulian iulianrotaru Data 28 mai 2016 11:25:23
Problema Consecutive Scor 0
Compilator cpp Status done
Runda ONIS 2016 - Runda - 2 - ACM ICPC Romanian Programming Contest Marime 0.56 kb
#include <fstream>
#define x first
#define y second
using namespace std;
ifstream f("consecutive.in");
ofstream g("consecutive.out");
int t,i,n;
pair <int,int> T[1<<20];
int main()
{
    f>>t;
    while(t--)
    {
        int s=3,nup=2,nr=0;
        f>>n;
        while(n>=s)
        {
            int corve=(n-s)/nup;
            if(corve*nup==(n-s))
                T[++nr]={corve+1,corve+nup};
            ++nup;
            s+=nup;
        }
        g<<nr<<'\n';
        for(i=1;i<=nr;++i) g<<T[i].x<<' '<<T[i].y<<'\n';
    }
    return 0;
}