Pagini recente » Cod sursa (job #2834911) | Cod sursa (job #2582821) | Cod sursa (job #2695869) | Cod sursa (job #20684) | Cod sursa (job #2059454)
#include <bits/stdc++.h>
typedef unsigned long long ull;
using namespace std;
vector< pair<ull, ull> > sol;
ifstream fin("consecutive.in");
ofstream fout("consecutive.out");
ull go(ull N)
{
ull count = 0;
for (ull L = 1; L * (L + 1) < 2 * N; L++)
{
float a = (1.0 * N - (L * (L + 1)) / 2) / (L + 1);
if (a - (ull)a == 0.0)
{
sol.push_back({a, a + L});
count++;
}
}
return count;
}
int main()
{
int t;
fin >> t;
while (t--)
{
ull n;
fin >> n;
sol.clear();
fout << go(n) << endl;
for (auto e : sol)
{
fout << e.first << " " << e.second << endl;
}
}
return 0;
}