Pagini recente » Cod sursa (job #2303198) | Cod sursa (job #2314469) | Cod sursa (job #1570762) | Cod sursa (job #3287922) | Cod sursa (job #1710283)
// http://www.infoarena.ro/problema/consecutive
#include "problems.h"
#define IN_FILE_NAME "consecutive.in"
#define OUT_FILE_NAME "consecutive.out"
#include <list>
using namespace std;
typedef long long int int64;
void RunConsecutive()
{
freopen(IN_FILE_NAME, "r", stdin);
freopen(OUT_FILE_NAME, "w", stdout);
int t, tests;
scanf("%d", &tests);
for (t = 0; t < tests; t++)
{
int64 S;
int i;
int n, m=1;
list<pair<int64, int64>> arr;
scanf("%lld", &S);
for (i = 2; ; i++)
{
int64 top = 2 * S - i*i - i;
if (top < 0)
break;
int64 bot = 2 * i;
if (top % bot == 0)
{
int64 m = top / bot;
int64 n = m + i;
m++;
arr.push_back(pair<int64, int64>(m, n));
}
}
printf("%d\n", arr.size());
while (!arr.empty())
{
pair<int64, int64> p = arr.front();
arr.pop_front();
printf("%lld %lld\n", p.first, p.second);
}
}
}