mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-27 13:56:26 +00:00
P1147 连续自然数和
R69143840
This commit is contained in:
parent
0c63ada187
commit
fe03814dae
23
Luogu/P1147/P1147.cpp
Normal file
23
Luogu/P1147/P1147.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user