結果
問題 | No.713 素数の和 |
ユーザー | Pump0129 |
提出日時 | 2018-07-17 13:37:12 |
言語 | Java21 (openjdk 21) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,080 bytes |
コンパイル時間 | 2,199 ms |
コンパイル使用メモリ | 76,040 KB |
実行使用メモリ | 54,496 KB |
最終ジャッジ日時 | 2024-05-03 18:31:39 |
合計ジャッジ時間 | 4,387 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 155 ms
54,260 KB |
testcase_01 | RE | - |
testcase_02 | AC | 129 ms
54,260 KB |
testcase_03 | AC | 140 ms
54,496 KB |
testcase_04 | AC | 149 ms
53,976 KB |
testcase_05 | AC | 150 ms
54,256 KB |
testcase_06 | AC | 126 ms
53,940 KB |
testcase_07 | AC | 125 ms
54,076 KB |
testcase_08 | AC | 145 ms
54,148 KB |
ソースコード
package net.ipipip0129.yukicoder.no713; import java.util.ArrayList; import java.util.List; import java.util.Scanner; class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int num = Integer.parseInt(scan.nextLine()); int sqrt_num = ((int)Math.sqrt(num)) + 1; List<Integer> num_list = new ArrayList<>(); for (int i = 0; i < num; i++) { num_list.add(i + 1); } int pt = 1; //エラトステネスの篩 while (true) { int pt_num = num_list.get(pt); if (sqrt_num <= pt_num) { break; } for(int i = pt_num * 2; i <= num; i += pt_num) { if (num_list.indexOf(i) != -1) { num_list.remove(num_list.indexOf(i)); } } pt++; } int add_num = 0; for (int ans_num : num_list) { add_num += ans_num; } System.out.println(add_num - 1); } }