結果
問題 | No.106 素数が嫌い!2 |
ユーザー | kenji_shioya |
提出日時 | 2016-06-29 04:07:28 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 2,010 ms / 5,000 ms |
コード長 | 718 bytes |
コンパイル時間 | 3,770 ms |
コンパイル使用メモリ | 74,500 KB |
実行使用メモリ | 41,592 KB |
最終ジャッジ日時 | 2024-04-20 03:58:04 |
合計ジャッジ時間 | 18,704 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 902 ms
41,336 KB |
testcase_01 | AC | 108 ms
41,384 KB |
testcase_02 | AC | 115 ms
41,208 KB |
testcase_03 | AC | 116 ms
41,464 KB |
testcase_04 | AC | 838 ms
41,536 KB |
testcase_05 | AC | 2,010 ms
40,060 KB |
testcase_06 | AC | 2,009 ms
41,240 KB |
testcase_07 | AC | 1,933 ms
41,356 KB |
testcase_08 | AC | 159 ms
41,460 KB |
testcase_09 | AC | 157 ms
41,568 KB |
testcase_10 | AC | 1,947 ms
41,512 KB |
testcase_11 | AC | 737 ms
41,592 KB |
testcase_12 | AC | 1,861 ms
41,160 KB |
testcase_13 | AC | 116 ms
41,292 KB |
testcase_14 | AC | 117 ms
41,108 KB |
testcase_15 | AC | 107 ms
41,432 KB |
ソースコード
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); } }