Ver código fonte

添加 'A.cpp'

爱玲姐姐 5 anos atrás
pai
commit
deabcc34c6
1 arquivos alterados com 22 adições e 0 exclusões
  1. 22 0
      A.cpp

+ 22 - 0
A.cpp

@@ -0,0 +1,22 @@
+#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;
+}