結果
| 問題 | No.106 素数が嫌い!2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-06-30 11:10:48 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 707 bytes |
| 記録 | |
| コンパイル時間 | 3,531 ms |
| コンパイル使用メモリ | 86,616 KB |
| 実行使用メモリ | 52,848 KB |
| 最終ジャッジ日時 | 2026-06-30 11:11:01 |
| 合計ジャッジ時間 | 5,969 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 WA * 7 |
ソースコード
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;
for(int i = 1;i*2 <= n;i++) {
nlist[i*2] = 1;
if(k == 1) {
count++;
}
}
for(int i = 3;i*i <= 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);
}
}