#include <cmath>
#include <iostream>
using namespace std;
int main(int argc, char **argv) {
long c, k, m, n, t;
scanf("%ld", &n);
t = (long)sqrt(2 * n);
c = 0;
for (k = 2; k <= t; k++) {
if ((2 * n) % k > 0 || (2 * n / k + 1 - k) % 2 > 0)
continue;
m = (2 * n / k + 1 - k) / 2;
c++;
cout << "%d: %d+...%d\n" << c << m << m + k - 1 << endl;
}
cout << "sum is:" << c << endl;
return 0;
}
运用求和公式拆分连续正整数之和
最新推荐文章于 2024-07-13 20:45:35 发布