diff --git a/bin/Main.class b/bin/Main.class index f69b942..a68ba83 100644 Binary files a/bin/Main.class and b/bin/Main.class differ diff --git a/exercise/bin/InsertSorted.class b/exercise/bin/InsertSorted.class deleted file mode 100644 index b3ed44a..0000000 Binary files a/exercise/bin/InsertSorted.class and /dev/null differ diff --git a/exercise/src/Main.class b/exercise/src/Main.class index f3f2a11..814daa6 100644 Binary files a/exercise/src/Main.class and b/exercise/src/Main.class differ diff --git a/exercise/src/Main.java b/exercise/src/Main.java index 8246aa4..412c35e 100644 --- a/exercise/src/Main.java +++ b/exercise/src/Main.java @@ -1,59 +1,10 @@ import java.util.Scanner; public class Main { - static boolean isPrime(int x) { - if (x < 2) - return false; - if (x % 2 == 0) - return x == 2; - for (int i = 3; i * i <= x; i += 2) { - if (x % i == 0) - return false; - } - return true; - } - - static boolean noZero(String s) { - for (int i = 0; i < s.length(); i++) - if (s.charAt(i) == '0') - return false; - return true; - } - public static void main(String[] args) { Scanner in = new Scanner(System.in); - String s = in.next().trim(); - boolean left = false, right = false; - if (noZero(s)) { - boolean ok = true; - for (int i = 0; i < s.length(); i++) { - int v = Integer.parseInt(s.substring(i)); - if (!isPrime(v)) { - ok = false; - break; - } - } - left = ok; - } - if (noZero(s)) { - boolean ok = true; - for (int i = s.length(); i >= 1; i--) { - int v = Integer.parseInt(s.substring(0, i)); - if (!isPrime(v)) { - ok = false; - break; - } - } - right = ok; - } - if (left && right) - System.out.println("both"); - else if (left) - System.out.println("left"); - else if (right) - System.out.println("right"); - else - System.out.println("false"); + int n = in.nextInt(); + System.out.println(n % 3 == 0 ? "hua" : "ming"); in.close(); } } \ No newline at end of file diff --git a/作业/作业/刘航宇-day35/第一题/Main.java b/作业/作业/刘航宇-day35/第一题/Main.java new file mode 100644 index 0000000..f01fe8a --- /dev/null +++ b/作业/作业/刘航宇-day35/第一题/Main.java @@ -0,0 +1,20 @@ +import java.util.Scanner; + +public class Main { + public static void main(String[] args) { + Scanner in = new Scanner(System.in); + String s = in.next(); + int[] cnt = new int[10]; + for (int i = 0; i < s.length(); i++) + cnt[s.charAt(i) - '0']++; + StringBuilder out = new StringBuilder(s.length()); + for (int d = 1; d <= 9; d++) { + for (int k = 0; k < cnt[d]; k++) + out.append((char) ('0' + d)); + } + for (int k = 0; k < cnt[0]; k++) + out.append('0'); + System.out.println(out.toString()); + in.close(); + } +} \ No newline at end of file diff --git a/作业/作业/刘航宇-day35/第一题/image.png b/作业/作业/刘航宇-day35/第一题/image.png new file mode 100644 index 0000000..78ee36a Binary files /dev/null and b/作业/作业/刘航宇-day35/第一题/image.png differ diff --git a/作业/作业/刘航宇-day35/第三题/Main.java b/作业/作业/刘航宇-day35/第三题/Main.java new file mode 100644 index 0000000..386f89b --- /dev/null +++ b/作业/作业/刘航宇-day35/第三题/Main.java @@ -0,0 +1,30 @@ +import java.util.Scanner; + +public class Main { + static long phi(long n) { + long res = n; + long x = n; + for (long p = 2; p * p <= x; p++) { + if (x % p == 0) { + while (x % p == 0) + x /= p; + res = res / p * (p - 1); + } + } + if (x > 1) + res = res / x * (x - 1); + return res; + } + + public static void main(String[] args) { + Scanner in = new Scanner(System.in); + long n = in.nextLong(); + long ans = 0; + if (n > 1) { + long ph = phi(n); + ans = (n - 1) - ph; + } + System.out.println(ans); + in.close(); + } +} \ No newline at end of file diff --git a/作业/作业/刘航宇-day35/第三题/image.png b/作业/作业/刘航宇-day35/第三题/image.png new file mode 100644 index 0000000..e69de29 diff --git a/作业/作业/刘航宇-day35/第二题/Main.java b/作业/作业/刘航宇-day35/第二题/Main.java new file mode 100644 index 0000000..0b2d15b --- /dev/null +++ b/作业/作业/刘航宇-day35/第二题/Main.java @@ -0,0 +1,38 @@ +import java.util.Scanner; + +public class Main { + public static void main(String[] args) { + Scanner in = new Scanner(System.in); + int n = Integer.parseInt(in.nextLine().trim()); + String[] arr = new String[n]; + for (int i = 0; i < n; i++) + arr[i] = in.nextLine(); + if (n == 0) { + System.out.println(""); + in.close(); + return; + } + String first = arr[0]; + boolean[] used = new boolean[65536]; + StringBuilder out = new StringBuilder(); + for (int i = 0; i < first.length(); i++) { + char c = first.charAt(i); + int idx = c; + if (used[idx]) + continue; + boolean ok = true; + for (int k = 1; k < n; k++) { + if (arr[k].indexOf(c) == -1) { + ok = false; + break; + } + } + if (ok) { + out.append(c); + used[idx] = true; + } + } + System.out.println(out.toString()); + in.close(); + } +} \ No newline at end of file diff --git a/作业/作业/刘航宇-day35/第二题/image.png b/作业/作业/刘航宇-day35/第二题/image.png new file mode 100644 index 0000000..06df8cc Binary files /dev/null and b/作业/作业/刘航宇-day35/第二题/image.png differ diff --git a/作业/作业/刘航宇-day36/第一题/Main.java b/作业/作业/刘航宇-day36/第一题/Main.java new file mode 100644 index 0000000..33cd59b --- /dev/null +++ b/作业/作业/刘航宇-day36/第一题/Main.java @@ -0,0 +1,34 @@ +import java.util.Scanner; + +public class Main { + public static void main(String[] args) { + Scanner in = new Scanner(System.in); + String text = in.nextLine(); + String broken = in.nextLine(); + boolean[] bad = new boolean[26]; + for (int i = 0; i < broken.length(); i++) + bad[broken.charAt(i) - 'a'] = true; + int count = 0; + boolean inWord = false; + boolean wordHasBad = false; + for (int i = 0; i < text.length(); i++) { + char ch = text.charAt(i); + if (ch == ' ') { + if (inWord) { + if (!wordHasBad) + count++; + inWord = false; + wordHasBad = false; + } + } else { + inWord = true; + if (bad[ch - 'a']) + wordHasBad = true; + } + } + if (inWord && !wordHasBad) + count++; + System.out.println(count); + in.close(); + } +} \ No newline at end of file diff --git a/作业/作业/刘航宇-day36/第一题/image.png b/作业/作业/刘航宇-day36/第一题/image.png new file mode 100644 index 0000000..23e38d3 Binary files /dev/null and b/作业/作业/刘航宇-day36/第一题/image.png differ diff --git a/作业/作业/刘航宇-day36/第三题/Main.java b/作业/作业/刘航宇-day36/第三题/Main.java new file mode 100644 index 0000000..33cd59b --- /dev/null +++ b/作业/作业/刘航宇-day36/第三题/Main.java @@ -0,0 +1,34 @@ +import java.util.Scanner; + +public class Main { + public static void main(String[] args) { + Scanner in = new Scanner(System.in); + String text = in.nextLine(); + String broken = in.nextLine(); + boolean[] bad = new boolean[26]; + for (int i = 0; i < broken.length(); i++) + bad[broken.charAt(i) - 'a'] = true; + int count = 0; + boolean inWord = false; + boolean wordHasBad = false; + for (int i = 0; i < text.length(); i++) { + char ch = text.charAt(i); + if (ch == ' ') { + if (inWord) { + if (!wordHasBad) + count++; + inWord = false; + wordHasBad = false; + } + } else { + inWord = true; + if (bad[ch - 'a']) + wordHasBad = true; + } + } + if (inWord && !wordHasBad) + count++; + System.out.println(count); + in.close(); + } +} \ No newline at end of file diff --git a/作业/作业/刘航宇-day36/第三题/image.png b/作业/作业/刘航宇-day36/第三题/image.png new file mode 100644 index 0000000..15d5439 Binary files /dev/null and b/作业/作业/刘航宇-day36/第三题/image.png differ diff --git a/作业/作业/刘航宇-day36/第二题/Main.java b/作业/作业/刘航宇-day36/第二题/Main.java new file mode 100644 index 0000000..33cd59b --- /dev/null +++ b/作业/作业/刘航宇-day36/第二题/Main.java @@ -0,0 +1,34 @@ +import java.util.Scanner; + +public class Main { + public static void main(String[] args) { + Scanner in = new Scanner(System.in); + String text = in.nextLine(); + String broken = in.nextLine(); + boolean[] bad = new boolean[26]; + for (int i = 0; i < broken.length(); i++) + bad[broken.charAt(i) - 'a'] = true; + int count = 0; + boolean inWord = false; + boolean wordHasBad = false; + for (int i = 0; i < text.length(); i++) { + char ch = text.charAt(i); + if (ch == ' ') { + if (inWord) { + if (!wordHasBad) + count++; + inWord = false; + wordHasBad = false; + } + } else { + inWord = true; + if (bad[ch - 'a']) + wordHasBad = true; + } + } + if (inWord && !wordHasBad) + count++; + System.out.println(count); + in.close(); + } +} \ No newline at end of file diff --git a/作业/作业/刘航宇-day36/第二题/image.png b/作业/作业/刘航宇-day36/第二题/image.png new file mode 100644 index 0000000..0fd908a Binary files /dev/null and b/作业/作业/刘航宇-day36/第二题/image.png differ diff --git a/作业/作业/刘航宇-day37/第一题/Main.java b/作业/作业/刘航宇-day37/第一题/Main.java new file mode 100644 index 0000000..ee9f4f6 --- /dev/null +++ b/作业/作业/刘航宇-day37/第一题/Main.java @@ -0,0 +1,15 @@ +import java.util.Scanner; + +public class Main { + public static void main(String[] args) { + Scanner in = new Scanner(System.in); + long n1 = in.nextLong(); + long n2 = in.nextLong(); + long l = Math.min(n1, n2), r = Math.max(n1, n2); + int[] perfects = {6, 28, 496, 8128, 33550336}; + int cnt = 0; + for (int x : perfects) if (x >= l && x <= r) cnt++; + System.out.println(cnt); + in.close(); + } +} \ No newline at end of file diff --git a/作业/作业/刘航宇-day37/第一题/image.png b/作业/作业/刘航宇-day37/第一题/image.png new file mode 100644 index 0000000..74f4a2f Binary files /dev/null and b/作业/作业/刘航宇-day37/第一题/image.png differ diff --git a/作业/作业/刘航宇-day37/第三题/Main.java b/作业/作业/刘航宇-day37/第三题/Main.java new file mode 100644 index 0000000..412c35e --- /dev/null +++ b/作业/作业/刘航宇-day37/第三题/Main.java @@ -0,0 +1,10 @@ +import java.util.Scanner; + +public class Main { + public static void main(String[] args) { + Scanner in = new Scanner(System.in); + int n = in.nextInt(); + System.out.println(n % 3 == 0 ? "hua" : "ming"); + in.close(); + } +} \ No newline at end of file diff --git a/作业/作业/刘航宇-day37/第三题/image.png b/作业/作业/刘航宇-day37/第三题/image.png new file mode 100644 index 0000000..67aef8b Binary files /dev/null and b/作业/作业/刘航宇-day37/第三题/image.png differ diff --git a/作业/作业/刘航宇-day37/第二题/Main.java b/作业/作业/刘航宇-day37/第二题/Main.java new file mode 100644 index 0000000..f2ee6cc --- /dev/null +++ b/作业/作业/刘航宇-day37/第二题/Main.java @@ -0,0 +1,14 @@ +import java.util.Scanner; + +public class Main { + public static void main(String[] args) { + Scanner in = new Scanner(System.in); + long n = in.nextLong(); + long cnt = 0; + for (long x = 13; x <= n; x += 13) { + if (String.valueOf(x).contains("13")) cnt++; + } + System.out.println(cnt); + in.close(); + } +} \ No newline at end of file diff --git a/作业/作业/刘航宇-day37/第二题/image.png b/作业/作业/刘航宇-day37/第二题/image.png new file mode 100644 index 0000000..eb471bd Binary files /dev/null and b/作业/作业/刘航宇-day37/第二题/image.png differ diff --git a/作业/压缩包/刘航宇-day35.zip b/作业/压缩包/刘航宇-day35.zip new file mode 100644 index 0000000..70a7a63 Binary files /dev/null and b/作业/压缩包/刘航宇-day35.zip differ diff --git a/作业/压缩包/刘航宇-day36.zip b/作业/压缩包/刘航宇-day36.zip new file mode 100644 index 0000000..e06e1cc Binary files /dev/null and b/作业/压缩包/刘航宇-day36.zip differ diff --git a/作业/压缩包/刘航宇-day37.zip b/作业/压缩包/刘航宇-day37.zip new file mode 100644 index 0000000..8ce8b1d Binary files /dev/null and b/作业/压缩包/刘航宇-day37.zip differ