結果
| 問題 | No.106 素数が嫌い!2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-06-30 11:17:30 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
AC
|
| 実行時間 | 113 ms / 5,000 ms |
| コード長 | 721 bytes |
| 記録 | |
| コンパイル時間 | 3,793 ms |
| コンパイル使用メモリ | 85,064 KB |
| 実行使用メモリ | 53,924 KB |
| 最終ジャッジ日時 | 2026-06-30 11:17:38 |
| 合計ジャッジ時間 | 6,188 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 |
ソースコード
import java.util.ArrayList;
import java.util.Scanner;
public class No106 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt() , k = scanner.nextInt();
scanner.close();
ArrayList<Integer> pList = new ArrayList<Integer>();
int[] nlist = new int[n+1];
nlist[2] = 1;
pList.add(2);
int count = 0;
if(k == 1) {
count = n-1;
}else {
for(int i = 1;i*2 <= n;i++) {
nlist[i*2] = 1;
}
for(int i = 3;i*2 <= n;i += 2) {
if(nlist[i]== 0 ) {
pList.add(i);
for(int j = 1;j * i <= n;j++) {
nlist[i*j] += 1;
if(nlist[i*j] == k) {
count++;
}
}
}
}
}
System.out.println(count);
}
}