Pagini recente » Cod sursa (job #1299315) | Cod sursa (job #2563257) | Cod sursa (job #2611722) | Cod sursa (job #1716510) | Cod sursa (job #2202628)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("consecutive.in");
ofstream g("consecutive.out");
int main()
{
int n, s = 1, sol = 0, suma_aux, t;
f >> t;
while(t)
{
f >> n;
/*for (int i = 2 ; s < n ; ++i) {
s += i;
if ((n-s) % i == 0) nrSol++;
}
cout << nrSol << "\n";
s = 1;
for (int i = 2 ; s < n ; ++i) {
s += i;
if ((n-s) % i == 0) {
cout << i+1 << " " << (n-s)
}
}*/
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++;
}
}
g << sol << '\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)
{
g << suma_aux / i << " " << suma_aux / i + i - 1 << '\n';
}
}
}
t--;
}
}