Cod sursa(job #1709055)

Utilizator UBB_HakunaMatataUBB Cozma Nechita Pop UBB_HakunaMatata Data 28 mai 2016 10:43:51
Problema Consecutive Scor 100
Compilator cpp Status done
Runda ONIS 2016 - Runda - 2 - ACM ICPC Romanian Programming Contest Marime 0.74 kb
#include <iostream>
#include <fstream>
#include <vector>

using namespace std;

ifstream fin("consecutive.in");
ofstream fout("consecutive.out");

vector<pair<int,int>> res;
#define cout fout
int main()
{
    int T,k,a;
    long long dr;
    unsigned int n;

    fin>>T;

    for(;T;--T)
    {
        fin>>n;

        res.clear();

        for(k=1;;++k)
        {
            dr=(long long)n*2-1ll*k*k-k;

            if(dr<=0) break;

            if(dr%((k+1)<<1)==0)
            {
                a=dr/((k+1)<<1);
                res.push_back({a,a+k});
            }
        }

        cout<<res.size()<<'\n';

        for(auto &it:res) cout<<it.first<<' '<<it.second<<'\n';



    }

    return 0;
}