Browse Source

三角数

爱玲姐姐 5 years ago
parent
commit
6c7a0fcfca
1 changed files with 31 additions and 0 deletions
  1. 31 0
      C.cpp

+ 31 - 0
C.cpp

@@ -0,0 +1,31 @@
+#include <bits/stdc++.h>
+ 
+using namespace std;
+int m;
+ 
+bool Find(int x) {
+    if (x * (x + 1) == m) {
+        return true;
+    }
+    return false;
+}
+ 
+int main() {
+    int n;
+    while (cin >> n) {
+        m = n <<= 1;
+        bool flag = false;
+        for (int i = 1; i < sqrt(m); i++) {
+            if (Find(i)) {
+                flag = true;
+                break;
+            }
+        }
+        if (flag) {
+            cout << "YES" << endl;
+        } else {
+            cout << "NO" << endl;
+        }
+    }
+    return 0;
+}