結果
問題 | No.106 素数が嫌い!2 |
ユーザー | tenten |
提出日時 | 2023-04-14 11:46:41 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 90 ms / 5,000 ms |
コード長 | 1,840 bytes |
コンパイル時間 | 2,899 ms |
コンパイル使用メモリ | 91,076 KB |
実行使用メモリ | 45,928 KB |
最終ジャッジ日時 | 2024-04-18 11:09:28 |
合計ジャッジ時間 | 4,215 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 69 ms
41,664 KB |
testcase_01 | AC | 50 ms
37,116 KB |
testcase_02 | AC | 48 ms
36,860 KB |
testcase_03 | AC | 46 ms
36,912 KB |
testcase_04 | AC | 72 ms
41,892 KB |
testcase_05 | AC | 83 ms
45,772 KB |
testcase_06 | AC | 89 ms
45,732 KB |
testcase_07 | AC | 90 ms
45,652 KB |
testcase_08 | AC | 56 ms
37,636 KB |
testcase_09 | AC | 62 ms
37,700 KB |
testcase_10 | AC | 82 ms
45,928 KB |
testcase_11 | AC | 67 ms
41,480 KB |
testcase_12 | AC | 78 ms
45,628 KB |
testcase_13 | AC | 50 ms
36,580 KB |
testcase_14 | AC | 48 ms
37,040 KB |
testcase_15 | AC | 49 ms
37,128 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(); int[] counts =new int[n + 1]; int ans = 0; for (int i = 2; i <= n; i++) { if (counts[i] == 0) { for (int j = 1; j * i <= n; j++) { counts[j * i]++; } } if (counts[i] >= 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(); } }