Cod sursa(job #2202649)

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

//stringstream rezzz;
vector <long long> sol1, sol2;
 
int main()
{
    long long n, suma_aux, t, sol = 0;
    f >> t;
    while(t--)
    {
        f >> n;
        sol = 0;
        // nrSol = 0;
        // s = 1;
        // for (long long i = 2 ; s < n ; ++i) {
        //     s += i;
        //     if ((n-s) % i == 0) 
        //         nrSol++;
        //     if ((n-s) % i == 0) {
        //         long long p = (n-s)/i;
        //         rezzz << p+1 << " " << p+i << "\n";
        //     }
        // }
        // g << nrSol << "\n";
        // g << rezzz.str();
        for(long long i = 2 ; i <= n; i++)
        {
         suma_aux = (i - 1) * i / 2;
         if(suma_aux >= n)
             break;
         else
         {
             suma_aux = n - suma_aux;
             if(suma_aux % i == 0)
             {
                 sol++;
                 sol1.push_back(suma_aux/i);
                 sol2.push_back(suma_aux/i + i - 1);
             }
         }
        }
        g << sol << '\n';
        for(long long i = 0; i < sol; i++)
        {
         g << sol1[i] << " " << sol2[i] << '\n';
        }
        sol1.clear();
        sol2.clear();
    }
    return 0;
}