12345678910111213141516171819202122 |
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long LL;
-
- const int MAXN = 2e6 + 10;
- LL a[MAXN];
-
- int main() {
- int n = 15;
- scanf("%d", &n);
- for (int i = 1; i <= n; i++)a[i] = i;
- partial_sum(a, a + n + 1, a);
- for (int i = 0; i <= n; i++) {
- LL x = a[i];
- LL key = x + n;
- int pos = lower_bound(a + i + 2, a + n + 1, key) - a;
- if (a[pos] == key) {
- printf("%d %d\n", i + 1, pos);
- }
- }
- return 0;
- }
|