Cod sursa(job #2059448)

Utilizator vvvictorvictor vvvictor Data 7 noiembrie 2017 00:57:48
Problema Consecutive Scor 0
Compilator cpp Status done
Runda Arhiva ICPC Marime 0.66 kb
#include <bits/stdc++.h>
using namespace std;
vector< pair<int, int> > sol;

ifstream fin("consecutive.in");
ofstream fout("consecutive.out");

long int go(long int N)
{
    long int count = 0;
    for (long int L = 1; L * (L + 1) < 2 * N; L++)
    {
        float a = (1.0 * N-(L * (L + 1)) / 2) / (L + 1);
        if (a-(int)a == 0.0) 
        {
        	sol.push_back({a, a + L});
        	count++;
        }           
    }
    return count;
}
 
int main()
{
    int t;
    fin >> t;

    while (t--)
    {
    	int n;
    	cin >> n;

    	fout << go(n) << endl;
    	for (auto e : sol)
    	{
    		fout << e.first << " " << e.second << endl;
    	}
    }
    return 0;
}