Cod sursa(job #2202652)

Utilizator dorin31Geman Dorin Andrei dorin31 Data 9 mai 2018 16:38:59
Problema Consecutive Scor 100
Compilator cpp Status done
Runda Arhiva ICPC Marime 1.26 kb
#include <bits/stdc++.h>
  
using namespace std;
 
ifstream f("consecutive.in");
ofstream g("consecutive.out");
 
vector <int> sol1, sol2;
 
int main()
{
    long long n, s = 1, nrSol = 0, suma_aux, t;
    f >> t;
    while(t--)
    {
        f >> n;
        s = 1;
        nrSol = 0;
        for (long long i = 2 ; s < n ; ++i) {
            s += i;
            if ((n-s) % i == 0) 
                nrSol++;
        }
        g << nrSol << "\n";
        s = 1;
        for (long long i = 2 ; s < n ; ++i) {
            s += i;
            if ((n-s) % i == 0) {
                long long p = (n-s)/i;
                g << p+1 << " " << p+i << "\n";
            }
        }
        // for(int i = 2 ; i < n / 2; 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(int i = 0; i < sol; i++)
        // {
        //  g << sol1[i] << " " << sol2[i] << '\n';
        // }
    }
    return 0;
}