結果
問題 |
No.713 素数の和
|
ユーザー |
|
提出日時 | 2023-08-06 18:33:23 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 487 bytes |
コンパイル時間 | 1,662 ms |
コンパイル使用メモリ | 195,356 KB |
最終ジャッジ日時 | 2025-02-15 23:48:15 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> primes(0); for (int i = 2; i <= n; ++i) { bool isPrime = true; for (auto j: primes) { if (i % j == 0) { isPrime = false; break; } } if (isPrime) primes.push_back(i); } int ans = 0; for (auto i: primes) { ans += i; } cout << ans << endl; }