Cod sursa(job #1975328)

Utilizator HumikoPostu Alexandru Humiko Data 30 aprilie 2017 14:54:31
Problema Consecutive Scor 0
Compilator cpp Status done
Runda Arhiva ICPC Marime 0.62 kb
#include <iostream>
#include <fstream>
#include <vector>
#include <utility>

using namespace std;

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

long long x, l;
vector <pair<int, int> > sol;

int main()
{int t;
f>>t;
while (t--){
    f>>x;
    sol.clear();

    for (l=2;l*(l+(long long)1)/l*(l+(long long)2)<=x;l++){
        long long aux=x-l*(l-(long long)1)/(long long)2;
        if (aux%l==0)
            sol.push_back(make_pair(aux/l,aux/l+l-1));
    }
    g<<sol.size()<<"\n";
    for(int i=0;i<sol.size();i++)
        g<<sol[i].first<<" "<<sol[i].second<<"\n";

}
return 0;
}