Forráskód Böngészése

上传文件至 ''

webturing 5 éve
szülő
commit
ef8a2d1fae
5 módosított fájl, 91 hozzáadás és 0 törlés
  1. 1 0
      A.cpp
  2. 36 0
      B.cpp
  3. 19 0
      C.cpp
  4. 17 0
      D.cpp
  5. 18 0
      D1.cpp

+ 1 - 0
A.cpp

@@ -0,0 +1 @@
+main(){}

+ 36 - 0
B.cpp

@@ -0,0 +1,36 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+inline int f(int n) {
+    int tot = 0;
+    while (n % 7 == 0) {
+        ++tot;
+        n /= 7;
+    }
+    return tot;
+}
+
+inline int g(int n) {
+    int tot = 0;
+    while (n > 0) {
+        if (n % 10 == 7)++tot;
+        n /= 10;
+    }
+    return tot;
+}
+
+int main() {
+    int T;
+    cin >> T;
+    while (T--) {
+        int L, R;
+        cin >> L >> R;
+        int tot = 0;
+        for (int n = L; n <= R; n++) {
+            tot += f(n) + g(n);
+        }
+        cout << tot << endl;
+    }
+    return 0;
+}

+ 19 - 0
C.cpp

@@ -0,0 +1,19 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main() {
+    int n;
+    cin >> n;
+    while (n--) {
+        int x;
+        cin >> x;
+        if (x % 2 == 0) {
+            cout << x - 4 << " " << 4 << endl;
+        } else {
+            cout << x - 9 << " " << 9 << endl;
+        }
+    }
+
+    return 0;
+}

+ 17 - 0
D.cpp

@@ -0,0 +1,17 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main() {
+    for (int a = 123; 3 * a <= 987; a++) {
+        int b = a * 2, c = 3 * a;
+        ostringstream oss;
+        oss << a << b << c;
+        string s = oss.str();
+        sort(s.begin(), s.end());
+        if (s == "123456789")
+            cout << a << b << c << endl;
+    }
+    return 0;
+}
+ 

+ 18 - 0
D1.cpp

@@ -0,0 +1,18 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main() {
+    int a[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
+    do {
+        int x = a[0] * 100 + a[1] * 10 + a[2];
+        int y = a[3] * 100 + a[4] * 10 + a[5];
+        int z = a[6] * 100 + a[7] * 10 + a[8];
+        if (y == 2 * x && z == 3 * x) {
+            cout << x << y << z << endl;
+
+        }
+    } while (next_permutation(a, a + 9));
+    return 0;
+}
+