結果
問題 | No.713 素数の和 |
ユーザー |
![]() |
提出日時 | 2018-07-22 09:47:54 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 438 bytes |
コンパイル時間 | 643 ms |
コンパイル使用メモリ | 61,696 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-26 05:08:10 |
合計ジャッジ時間 | 1,357 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 |
ソースコード
#include <fstream>#include <iostream>#include <vector>int main() {//std::ifstream inf("Text.txt"); std::cin.rdbuf(inf.rdbuf());int N;std::cin >> N;std::vector<bool> flg(N + 1, true);for (int i = 2; i*i <= N; i++) {if (flg[i]) {for (int j = i + i; j <= N; j += i) {flg[j] = false;}}}int ans = 0;for (int i = 2; i <= N; i++) {ans += i * flg[i];}std::cout << ans << std::endl;return 0;}