Cod sursa(job #1710358)

Utilizator DenisONIcBanu Denis Andrei DenisONIc Data 28 mai 2016 20:42:29
Problema Consecutive Scor 0
Compilator cpp Status done
Runda Arhiva ICPC Marime 0.66 kb
#include <fstream>
#include <vector>
using namespace std;

ifstream f("consecutive.in");
ofstream g("consecutive.out");

long n,y,t;

struct ab{
    int a,b;
}aux;
vector <ab> v;
int main()
{
    f>>t;
    while (--t>=0)
    {
        f>>n;
        v.clear();
        y=2;
        while (y*y<n*2+1)
        {
            if ((2*n-y*y+y)%(2*y)==0)
            {
                aux.a=(2*n-y*y+y)/(2*y);
                aux.b=aux.a+y-1;
                v.push_back(aux);
            }
            y++;
        }

        g<<v.size()<<'\n';
        for (int i=0;i<v.size();i++)
            g<<v[i].a<<' '<<v[i].b<<'\n';
    }

    return 0;
}