Cod sursa(job #1710121)

Utilizator tamionvTamio Vesa Nakajima tamionv Data 28 mai 2016 15:58:18
Problema Consecutive Scor 100
Compilator cpp Status done
Runda Arhiva ICPC Marime 0.63 kb
#include <fstream>
#include <utility>
#include <vector>
#include <string>
using namespace std;

const string filename = "consecutive";

void do_test(ifstream& f, ofstream& g){
	long long n;
	f >> n;

	vector<pair<int, int>> rez;

	for(long long len = 2, min_sum = 3; min_sum <= n; ++len, min_sum += len){
		if((n-min_sum) % len == 0){
			rez.emplace_back((n-min_sum) / len + 1, len); } }

	g << rez.size() << '\n';
	for(const auto x : rez){
		g << x.first << ' ' << x.first + x.second - 1 << '\n'; } }

int main(){
	ifstream f(filename + ".in");
	ofstream g(filename + ".out");

	int t;

	for(f >> t; t; --t){
		do_test(f, g); }
	return 0; }