Cod sursa(job #1712153)

Utilizator Cristian1997Vintur Cristian Cristian1997 Data 2 iunie 2016 10:28:00
Problema Consecutive Scor 100
Compilator cpp Status done
Runda Arhiva ICPC Marime 0.71 kb
using namespace std;
#include <fstream>
#include <vector>
#include <algorithm>
#include <string>
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

vector< pll > sol;

int main()
{
	int t;
	ll n, lg, x;
	ifstream fin("consecutive.in");
	ofstream fout("consecutive.out");

	for (fin >> t; t; --t)
	{
		fin >> n;

		sol.clear();
		for (lg = 2; lg * lg < 2 * n; ++lg)
			if ((2 * n) % lg == 0)
			{
				x = (2 * n) / lg - lg + 1;

				if (x > 0 && x % 2 == 0) sol.emplace_back(x / 2, x / 2 + lg - 1);
			}

		fout << sol.size() << '\n';
		for (auto &sum : sol) fout << sum.first << ' ' << sum.second << '\n';
	}

	fin.close();
	fout.close();

    return 0;
}