Cod sursa(job #1708984)

Utilizator UBB2NibblesFromHellAlexandru Duma UBB2NibblesFromHell Data 28 mai 2016 10:26:54
Problema Consecutive Scor 0
Compilator cpp Status done
Runda ONIS 2016 - Runda - 2 - ACM ICPC Romanian Programming Contest Marime 0.83 kb
// 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;
}