結果
問題 | No.106 素数が嫌い!2 |
ユーザー |
![]() |
提出日時 | 2016-06-29 04:07:28 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 2,126 ms / 5,000 ms |
コード長 | 718 bytes |
コンパイル時間 | 5,632 ms |
コンパイル使用メモリ | 73,788 KB |
実行使用メモリ | 54,232 KB |
最終ジャッジ日時 | 2024-10-11 22:51:48 |
合計ジャッジ時間 | 21,420 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 |
ソースコード
import java.util.*; public class Exercise137{ public static void main (String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); int count = 0; for(int i = 2; i < n + 1; i++){ int x = i; int pCount = 0; int lastNum = 2; if(x % 2 == 0){ pCount++; } while(x % 2 == 0){ x /= 2; } for(int j = 3; j * j <= x; j += 2){ if(x % j == 0){ pCount++; } while(x % j == 0){ x /= j; } lastNum = j; } if(x > lastNum){ pCount++; } if(pCount >= k){ count++; } } System.out.println(count); } }