0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-09 16:38:47 +00:00

P1147 连续自然数和

R69143840
This commit is contained in:
Baoshuo Ren 2022-02-12 10:08:28 +08:00
parent 0c63ada187
commit fe03814dae
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

23
Luogu/P1147/P1147.cpp Normal file
View File

@ -0,0 +1,23 @@
#include <iostream>
using std::cin;
using std::cout;
#define endl '\n'
int m, sum, j;
int main() {
std::ios::sync_with_stdio(false);
cin >> m;
for (int i = 1; i <= m / 2; i++) {
sum = 0;
for (j = i; j < m; j++) {
sum += j;
if (sum >= m) break;
}
if (sum == m) {
cout << i << ' ' << j << endl;
}
}
return 0;
}