Cod sursa(job #2202644)

Utilizator dorin31Geman Dorin Andrei dorin31 Data 9 mai 2018 16:27:56
Problema Consecutive Scor 0
Compilator cpp Status done
Runda Arhiva ICPC Marime 0.58 kb
#include <bits/stdc++.h>
 
using namespace std;
 
ifstream f("consecutive.in");
ofstream g("consecutive.out");

stringstream rezzz;
 
int main()
{
    long n, s, t, nrSol = 0;
    f >> t;
    while(t--)
    {
        f >> n;
        nrSol = 0;
        s = 1;
        for (int i = 2 ; s < n ; ++i) {
            s += i;
            if ((n-s) % i == 0) 
                nrSol++;
            if ((n-s) % i == 0) {
                long p = (n-s)/i;
                rezzz << p+1 << " " << p+i << "\n";
            }
        }
        g << nrSol << "\n";
        g << rezzz.str();
    }
    return 0;
}