소스 검색

添加 'A.cpp'

爱玲姐姐 5 년 전
부모
커밋
deabcc34c6
1개의 변경된 파일22개의 추가작업 그리고 0개의 파일을 삭제
  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;
+}