A.cpp 482 B

12345678910111213141516171819202122
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long LL;
  4. const int MAXN = 2e6 + 10;
  5. LL a[MAXN];
  6. int main() {
  7. int n = 15;
  8. scanf("%d", &n);
  9. for (int i = 1; i <= n; i++)a[i] = i;
  10. partial_sum(a, a + n + 1, a);
  11. for (int i = 0; i <= n; i++) {
  12. LL x = a[i];
  13. LL key = x + n;
  14. int pos = lower_bound(a + i + 2, a + n + 1, key) - a;
  15. if (a[pos] == key) {
  16. printf("%d %d\n", i + 1, pos);
  17. }
  18. }
  19. return 0;
  20. }