Pagini recente » Cod sursa (job #1112035) | Cod sursa (job #1171888) | Cod sursa (job #2094548) | Cod sursa (job #409711) | Cod sursa (job #2201810)
#include <iostream>
#include <fstream>
#include <vector>
namespace iordania {
std::ifstream citire("consecutive.in");
std::ofstream scriere("consecutive.out");
};
using namespace iordania;
int main() {
long long t, n, foundNumber, j;
double calculatedVal;
std::vector<std::pair<long long, long long>> foundNumbers;
citire >> t;
for (int i = 0; i < t; ++i) {
citire >> n;
j = 2;
foundNumber = 3;
while (foundNumber <= n) {
calculatedVal = (n - (float)foundNumber)/j + 1;
if (calculatedVal - (long long)calculatedVal == 0) {
foundNumbers.emplace_back(std::make_pair(calculatedVal, calculatedVal+j-1));
}
++j;
foundNumber += j;
}
unsigned long numbersOfElement = foundNumbers.size();
if (numbersOfElement) {
scriere << numbersOfElement << '\n';
for (auto it : foundNumbers) {
scriere << it.first << " " << it.second << '\n';
}
}
}
return 0;
}