diff --git "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257/\345\210\206\347\261\273\350\256\241\346\225\260/solution.md" "b/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257/\345\210\206\347\261\273\350\256\241\346\225\260/solution.md" index b3116ebd80cf69e7c04fafc2d8c677c36c60ffc0..96dd47dc1dcc8cecfe05396244c85002e1573ff6 100644 --- "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257/\345\210\206\347\261\273\350\256\241\346\225\260/solution.md" +++ "b/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257/\345\210\206\347\261\273\350\256\241\346\225\260/solution.md" @@ -26,7 +26,8 @@ ## aop ### before ```cpp - +#include +using namespace std; ``` ### after ```cpp @@ -35,21 +36,122 @@ ## 答案 ```cpp +int main(int argc, char **argv) +{ + string str; + cin >> str; + int A = 0, a = 0, number = 0; + int len = str.length(); + for (int i = 0; i < len; i++) + { + if (str[i] <= '9' && str[i] >= '0') + { + number++; + } + if (str[i] <= 'Z' && str[i] >= 'A') + { + A++; + } + if (str[i] <= 'z' && str[i] >= 'a') + { + a++; + } + } + cout << A << endl; + cout << a << endl; + cout << number << endl; + return 0; +} ``` ## 选项 ### A ```cpp - +int main(int argc, char **argv) +{ + string str; + cin >> str; + int A = 0, a = 0, number = 0; + int len = str.length(); + for (int i = 0; i < len; i++) + { + if (str[i] < '9' && str[i] > '0') + { + number++; + } + if (str[i] < 'Z' && str[i] > 'A') + { + A++; + } + if (str[i] < 'z' && str[i] > 'a') + { + a++; + } + } + cout << A << endl; + cout << a << endl; + cout << number << endl; + return 0; +} ``` ### B ```cpp - +int main(int argc, char **argv) +{ + string str; + cin >> str; + int A = 0, a = 0, number = 0; + int len = str.length(); + for (int i = 0; i < len; i++) + { + if (str[i] < 71 && str[i] > 60) + { + number++; + } + if (str[i] < 132 && str[i] > 101) + { + A++; + } + if (str[i] < 172 && str[i] > 141) + { + a++; + } + } + cout << A << endl; + cout << a << endl; + cout << number << endl; + return 0; +} ``` ### C ```cpp - +int main(int argc, char **argv) +{ + string str; + cin >> str; + int A = 0, a = 0, number = 0; + int len = str.length(); + for (int i = 0; i < len; i++) + { + if (str[i] < 39 && str[i] > 30) + { + number++; + } + if (str[i] < 132 && str[i] > 101) + { + A++; + } + if (str[i] <= 'z' && str[i] >= 'a') + { + a++; + } + } + cout << A << endl; + cout << a << endl; + cout << number << endl; + return 0; +} ``` diff --git "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257/\345\210\206\351\205\215\345\217\243\347\275\251/solution.md" "b/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257/\345\210\206\351\205\215\345\217\243\347\275\251/solution.md" index 3431e59ff9b539a19a8b0e48ebd1f0dfba03446d..047b2d12c4df72654547eea2e1d91d2b0050ce9a 100644 --- "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257/\345\210\206\351\205\215\345\217\243\347\275\251/solution.md" +++ "b/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257/\345\210\206\351\205\215\345\217\243\347\275\251/solution.md" @@ -14,30 +14,80 @@ masks = [9090400, 8499400, 5926800, 8547000, 4958200, 4422600, 5751200, 4175600, ## aop ### before ```cpp +#include +#include +#include +using namespace std; +long int masks[15] = {9090400, 8499400, 5926800, 8547000, 4958200, + 4422600, 5751200, 4175600, 6309600, + 5865200, 6604400, 4635000, 10663400, 8087200, 4554000}; +long ans = 1000000000; ``` ### after ```cpp +int main() +{ + dfs(0, 0, 0); + cout << ans; +} ``` ## 答案 ```cpp +void dfs(int n, long h1, long h2) +{ + if (n == 15) + { + ans = min(ans, abs(h1 - h2)); + return; + } + dfs(n + 1, h1 + masks[n], h2); + dfs(n + 1, h1, h2 + masks[n]); +} ``` ## 选项 ### A ```cpp - +void dfs(int n, long h1, long h2) +{ + if (n == 15) + { + ans = min(ans, abs(h1 - h2)); + return; + } + dfs(n + 1, h1 + masks[n + 1], h2); + dfs(n + 1, h1, h2 + masks[n + 1]); +} ``` ### B ```cpp - +void dfs(int n, long h1, long h2) +{ + if (n == 15) + { + ans = min(ans, abs(h1 - h2)); + return; + } + dfs(n + 1, h1 + masks[n + 1], h2); + dfs(n + 1, h1, h2 + masks[n]); +} ``` ### C ```cpp - +void dfs(int n, long h1, long h2) +{ + if (n == 15) + { + ans = min(ans, abs(h1 - h2)); + return; + } + dfs(n, h1 + masks[n], h2); + dfs(n, h1, h2 + masks[n]); +} ``` diff --git "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257/\346\226\220\346\263\242\351\202\243\345\245\221/solution.md" "b/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257/\346\226\220\346\263\242\351\202\243\345\245\221/solution.md" index a13e044772c1dc175e5daf22d8357f66148e4f22..ff697d7a21e3f383785bee349a55ea8d3c352452 100644 --- "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257/\346\226\220\346\263\242\351\202\243\345\245\221/solution.md" +++ "b/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257/\346\226\220\346\263\242\351\202\243\345\245\221/solution.md" @@ -30,7 +30,7 @@ Fibonacci数列的递推公式为:Fn=Fn-1+Fn-2,其中F1=F2=1。 ## aop ### before ```cpp - +#include ``` ### after ```cpp @@ -39,21 +39,89 @@ Fibonacci数列的递推公式为:Fn=Fn-1+Fn-2,其中F1=F2=1。 ## 答案 ```cpp +int main() +{ + int n, b; + scanf("%d", &n); + int a[n]; + a[0] = a[1] = 1; + for (int i = 2; i < n; i++) + { + a[i] = (a[i - 1] + a[i - 2]) % 10007; + b = a[i]; + } + if (n > 2) + printf("%d", b); + else + printf("1"); + return 0; +} ``` ## 选项 ### A ```cpp +int main() +{ + int n, b; + scanf("%d", &n); + int a[n]; + a[0] = a[1] = 1; + for (int i = 2; i < n; i++) + { + a[i] = (a[i - 1] + a[i - 2]) % 10007; + b = a[i] + 1; + } + if (n > 2) + printf("%d", b); + else + printf("1"); + return 0; +} ``` ### B ```cpp +int main() +{ + int n, b; + scanf("%d", &n); + int a[n]; + a[0] = a[1] = 1; + for (int i = 2; i < n; i++) + { + a[i] = (a[i - 1] + a[i - 2]) % 10007; + b = a[i - 1]; + } + if (n > 2) + printf("%d", b); + else + printf("1"); + return 0; +} ``` ### C ```cpp +int main() +{ + int n, b; + scanf("%d", &n); + int a[n]; + a[0] = a[1] = 1; + for (int i = 2; i < n; i++) + { + a[i] = (a[i - 1] + a[i - 2]) % 10007; + b = a[i - 2]; + } + if (n > 2) + printf("%d", b); + else + printf("1"); + return 0; +} ``` diff --git "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257/\346\226\220\346\263\242\351\202\243\345\245\221\346\225\260\345\210\227\346\234\200\345\244\247\345\205\254\347\272\246\346\225\260/config.json" "b/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257/\346\226\220\346\263\242\351\202\243\345\245\221\346\225\260\345\210\227\346\234\200\345\244\247\345\205\254\347\272\246\346\225\260/config.json" deleted file mode 100644 index f6416a1a57a86a638c71ad1c8742a38349a88fe3..0000000000000000000000000000000000000000 --- "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257/\346\226\220\346\263\242\351\202\243\345\245\221\346\225\260\345\210\227\346\234\200\345\244\247\345\205\254\347\272\246\346\225\260/config.json" +++ /dev/null @@ -1,6 +0,0 @@ -{ - "node_id": "569d5e11c4fc5de7844053d9a733c5e8", - "keywords": [], - "children": [], - "export": [] -} \ No newline at end of file diff --git "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257/\346\226\220\346\263\242\351\202\243\345\245\221\346\225\260\345\210\227\346\234\200\345\244\247\345\205\254\347\272\246\346\225\260/desc.md" "b/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257/\346\226\220\346\263\242\351\202\243\345\245\221\346\225\260\345\210\227\346\234\200\345\244\247\345\205\254\347\272\246\346\225\260/desc.md" deleted file mode 100644 index 2dddfe962cc3b307ee5cc86f9ec07d2288ae6f90..0000000000000000000000000000000000000000 --- "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257/\346\226\220\346\263\242\351\202\243\345\245\221\346\225\260\345\210\227\346\234\200\345\244\247\345\205\254\347\272\246\346\225\260/desc.md" +++ /dev/null @@ -1,2 +0,0 @@ -#### 问题描述 -斐波那契数列满足 F1 = F2 = 1,从 F3 开始有 Fn = Fn−1 + Fn−2。请你计算 GCD(F2020, F520),其中 GCD(A, B) 表示 A 和 B 的最大公约数。 \ No newline at end of file diff --git "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257/\346\226\220\346\263\242\351\202\243\345\245\221\346\225\260\345\210\227\346\234\200\345\244\247\345\205\254\347\272\246\346\225\260/solution.cpp" "b/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257/\346\226\220\346\263\242\351\202\243\345\245\221\346\225\260\345\210\227\346\234\200\345\244\247\345\205\254\347\272\246\346\225\260/solution.cpp" deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257/\346\226\220\346\263\242\351\202\243\345\245\221\346\225\260\345\210\227\346\234\200\345\244\247\345\205\254\347\272\246\346\225\260/solution.java" "b/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257/\346\226\220\346\263\242\351\202\243\345\245\221\346\225\260\345\210\227\346\234\200\345\244\247\345\205\254\347\272\246\346\225\260/solution.java" deleted file mode 100644 index 6641fde7213038e5b575ab71bfe6c275786dc4c8..0000000000000000000000000000000000000000 --- "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257/\346\226\220\346\263\242\351\202\243\345\245\221\346\225\260\345\210\227\346\234\200\345\244\247\345\205\254\347\272\246\346\225\260/solution.java" +++ /dev/null @@ -1,24 +0,0 @@ - -import java.math.BigInteger; - -public class BigNumber { - public static void main(String[] args) { - BigInteger a = new BigInteger("1"); - BigInteger b = new BigInteger("1"); - BigInteger[] fib = new BigInteger[2030]; - fib[1] = a; - fib[2] = b; - for (int x = 3; x < fib.length; x++) { - fib[x] = fib[x - 1].add(fib[x - 2]); - } - a = fib[2020]; - b = fib[520]; - BigInteger temp; - while (b != BigInteger.ZERO) { - temp = a.mod(b); - a = b; - b = temp; - } - System.out.println(a); - } -} diff --git "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257/\346\226\220\346\263\242\351\202\243\345\245\221\346\225\260\345\210\227\346\234\200\345\244\247\345\205\254\347\272\246\346\225\260/solution.md" "b/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257/\346\226\220\346\263\242\351\202\243\345\245\221\346\225\260\345\210\227\346\234\200\345\244\247\345\205\254\347\272\246\346\225\260/solution.md" deleted file mode 100644 index bea7b72851b26dc5c5cdfbd368625531eb2fadc0..0000000000000000000000000000000000000000 --- "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257/\346\226\220\346\263\242\351\202\243\345\245\221\346\225\260\345\210\227\346\234\200\345\244\247\345\205\254\347\272\246\346\225\260/solution.md" +++ /dev/null @@ -1,34 +0,0 @@ -# 斐波那契数列最大公约数 -#### 问题描述 -斐波那契数列满足 F1 = F2 = 1,从 F3 开始有 Fn = Fn−1 + Fn−2。请你计算 GCD(F2020, F520),其中 GCD(A, B) 表示 A 和 B 的最大公约数。 - -## aop -### before -```cpp - -``` -### after -```cpp - -``` - -## 答案 -```cpp - -``` -## 选项 - -### A -```cpp - -``` - -### B -```cpp - -``` - -### C -```cpp - -```