結果
問題 | No.713 素数の和 |
ユーザー | matsuyoshi30 |
提出日時 | 2018-10-09 22:54:02 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 122 ms / 2,000 ms |
コード長 | 635 bytes |
コンパイル時間 | 2,015 ms |
コンパイル使用メモリ | 73,900 KB |
実行使用メモリ | 41,420 KB |
最終ジャッジ日時 | 2024-04-20 19:19:40 |
合計ジャッジ時間 | 3,733 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 122 ms
41,232 KB |
testcase_01 | AC | 107 ms
39,960 KB |
testcase_02 | AC | 115 ms
41,048 KB |
testcase_03 | AC | 114 ms
41,420 KB |
testcase_04 | AC | 118 ms
41,124 KB |
testcase_05 | AC | 109 ms
40,656 KB |
testcase_06 | AC | 113 ms
41,244 KB |
testcase_07 | AC | 110 ms
41,388 KB |
testcase_08 | AC | 116 ms
41,308 KB |
ソースコード
import java.util.*; class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); if(n == 1) { System.out.println(0); return; } int sum = 0; for(int i=2; i<=n; i++) sum += primeNum(i); System.out.println(sum); } public static int primeNum(int x) { boolean flag = true; for(int i=2; i<=x-1; i++) { if(x % i == 0) { flag = false; break; } } if(flag) return x; else return 0; } }