更新
@@ -1,59 +1,10 @@
|
|||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
public class Main {
|
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) {
|
public static void main(String[] args) {
|
||||||
Scanner in = new Scanner(System.in);
|
Scanner in = new Scanner(System.in);
|
||||||
String s = in.next().trim();
|
int n = in.nextInt();
|
||||||
boolean left = false, right = false;
|
System.out.println(n % 3 == 0 ? "hua" : "ming");
|
||||||
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");
|
|
||||||
in.close();
|
in.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 2.3 MiB |
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 1.8 MiB |
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 1.8 MiB |
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 2.0 MiB |
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 2.0 MiB |
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 2.3 MiB |
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 2.2 MiB |
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 2.3 MiB |