java
Java での Set の使い方
import java.util.Scanner;
import java.util.Set;
import java.util.HashSet;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
Set<Integer> set = new HashSet<>();
for (int i = 1; i < 10; i++) {
for (int l = i; l < 10; l++) {
set.add(i * l);
}
}
if (set.contains(n)) {
System.out.println("Yes");
} else {
System.out.println("No");
}
}
}
Was this helpful?
Similar Posts