結果
問題 | No.106 素数が嫌い!2 |
ユーザー |
|
提出日時 | 2015-11-23 20:05:07 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 169 ms / 5,000 ms |
コード長 | 610 bytes |
コンパイル時間 | 3,326 ms |
コンパイル使用メモリ | 74,304 KB |
実行使用メモリ | 49,240 KB |
最終ジャッジ日時 | 2024-09-13 17:17:41 |
合計ジャッジ時間 | 6,580 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 |
ソースコード
import java.util.Scanner; public class Main_yukicoder106 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); int[] cnt = new int[n + 1]; for (int i = 2; i <= n; i++) { if (cnt[i] == 0) { for (int j = 1; i * j <= n; j++) { cnt[i * j]++; } } } int ret = 0; for (int i = 2; i <= n; i++) { if (cnt[i] >= k) { ret++; } } System.out.println(ret); sc.close(); } }