結果
| 問題 | No.713 素数の和 |
| コンテスト | |
| ユーザー |
@abcde
|
| 提出日時 | 2019-02-25 22:47:50 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 619 bytes |
| 記録 | |
| コンパイル時間 | 977 ms |
| コンパイル使用メモリ | 175,536 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-03 17:33:37 |
| 合計ジャッジ時間 | 1,810 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
// 1. 入力情報取得.
int N;
cin >> N;
// 2. 素数を用意する.
// AtCoder Beginner Contest 084
// https://atcoder.jp/contests/abc084
int ans = 2;
for(int i = 3; i < N + 1; i += 2) {
bool isPrime = true;
for(int j = 3; j < sqrt(i) + 1; j += 2) {
if(i % j == 0){
isPrime = false;
break;
}
}
if(isPrime) ans += i;
}
// 3. 出力 ~ 終了.
if(N == 1) ans = 0;
cout << ans << endl;
return 0;
}
@abcde