Pagini recente » Cod sursa (job #2990894) | Autentificare | Cod sursa (job #2723843) | Cod sursa (job #1245398) | Cod sursa (job #2202643)
#include <iostream>
#include <fstream>
#include <vector>
#include <sstream>
using namespace std;
ifstream f("consecutive.in");
ofstream g("consecutive.out");
vector <int> sol1, sol2;
stringstream rezzz;
int main()
{
int 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) {
int p = (n-s)/i;
rezzz << p+1 << " " << p+i << "\n";
}
}
g << nrSol << "\n";
g << rezzz.str();
}
return 0;
}