Pagini recente » Cod sursa (job #2977545) | Cod sursa (job #3294730) | Cod sursa (job #1428140) | Cod sursa (job #2359226) | Cod sursa (job #1708984)
// ACM_A.cpp : Defines the entry point for the console application.
//
//#include "stdafx.h"
#include <vector>
#include <fstream>
using namespace std;
class pp {
public:
int a, b;
pp(int a, int b) :a{ a }, b{ b } {};
};
int main()
{
ifstream f("consecutive.in");
ofstream g("consecutive.out");
vector<pp> v;
int t;
long long int n;
int partialSum = 0;
int nRez;
f>> t;
int j;
int i;
for ( j = 0; j < t; j++) {
v.clear();
f >> n;
nRez = n;
partialSum = 0;
for (i = 1; (n - partialSum) / i > 0; i++) {
nRez -= i;
if (nRez % (i+1) == 0 && nRez / (i + 1) > 0) {
v.push_back(pp{ nRez / (i+1),nRez / (i+1) + i });
}
}
g << v.size() << endl;
for (int i = 0; i < v.size(); i++)
g << v[i].a << " " << v[i].b << endl;
}
f.close();
g.close();
return 0;
}