Cod sursa(job #2008308)

Utilizator moise_alexandruMoise Alexandru moise_alexandru Data 6 august 2017 03:23:47
Problema Consecutive Scor 100
Compilator cpp Status done
Runda Arhiva ICPC Marime 0.7 kb
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream in("consecutive.in");
ofstream out("consecutive.out");
vector <pair <int, int> > sol;
void solve()
{
    sol.clear();
    long long n;
    in >> n;
    long long p = 2;
    while(p * (p - 1) / 2 < n)
    {
        //cerr << "intra";
        int aux = n - p * (p - 1) / 2;
        if(aux % p == 0)
            sol.push_back(make_pair(aux / p, aux / p + p - 1));
        p++;
    }
    out << sol.size() << "\n";
    for(auto it : sol)
        out << it.first << " " << it.second << "\n";
}

int main()
{
    int T;
    in >> T;
    for(int i = 1; i <= T; i++)
        solve();
    return 0;
}