結果
問題 | No.106 素数が嫌い!2 |
ユーザー | tenten |
提出日時 | 2023-12-18 11:07:34 |
言語 | Java21 (openjdk 21) |
結果 |
MLE
|
実行時間 | - |
コード長 | 2,129 bytes |
コンパイル時間 | 2,791 ms |
コンパイル使用メモリ | 84,768 KB |
実行使用メモリ | 651,720 KB |
最終ジャッジ日時 | 2023-12-18 11:08:18 |
合計ジャッジ時間 | 35,127 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2,222 ms
340,536 KB |
testcase_01 | AC | 57 ms
53,996 KB |
testcase_02 | AC | 56 ms
53,992 KB |
testcase_03 | AC | 57 ms
54,000 KB |
testcase_04 | AC | 2,062 ms
340,520 KB |
testcase_05 | MLE | - |
testcase_06 | MLE | - |
testcase_07 | MLE | - |
testcase_08 | AC | 487 ms
87,864 KB |
testcase_09 | AC | 481 ms
90,520 KB |
testcase_10 | MLE | - |
testcase_11 | AC | 2,113 ms
339,024 KB |
testcase_12 | MLE | - |
testcase_13 | AC | 56 ms
53,952 KB |
testcase_14 | AC | 57 ms
54,000 KB |
testcase_15 | AC | 61 ms
54,000 KB |
ソースコード
import java.io.*; import java.util.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int k = sc.nextInt(); ArrayList<HashSet<Integer>> counts = new ArrayList<>(); int[] nums = new int[n + 1]; for (int i = 0; i <= n; i++) { counts.add(new HashSet<>()); nums[i] = i; } int ans = 0; for (int i = 2; i <= n; i++) { if (nums[i] > 1) { for (int j = 2; j * i <= n; j++) { nums[j * i] /= nums[i]; counts.get(j * i).add(nums[i]); } counts.get(i).add(nums[i]); } if (counts.get(i).size() >= k) { ans++; } } System.out.println(ans); } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }