Cod sursa(job #3364670)

Utilizator lambrulescu@outlook.comMatei Lambrulescu [email protected] Data 8 septembrie 2026 22:08:19
Problema Consecutive Scor 100
Compilator cpp-64 Status done
Runda Arhiva ICPC Marime 0.88 kb
#include <fstream>
#include <algorithm>

using namespace std;

ifstream cin("consecutive.in");
ofstream cout("consecutive.out");

struct ura
{
    long long x;
    long long y;
    long long dif;
};

ura v[100000];

int main()
{
    int T;
    cin>>T;
    while(T--)
    {
        long long n;
        cin>>n;
        int cnt=0;
        for(long long d=2;d*d<=2*n;d++)
        {
            if((2*n)%d==0)
            {
                long long z=2*n/d-d+1;
                if(z>0 and z%2==0)
                {
                    long long x=z/2;
                    long long y=x+d-1;
                    v[++cnt].x=x;
                    v[cnt].y=y;
                    v[cnt].dif=y-x+1;
                }
            }
        }
        cout<<cnt<<"\n";
        for(int i=1;i<=cnt;i++)
            cout<<v[i].x<<" "<<v[i].y<<"\n";
    }
    return 0;
}