結果
| 問題 |
No.713 素数の和
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-01-02 15:00:22 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 541 bytes |
| コンパイル時間 | 1,124 ms |
| コンパイル使用メモリ | 79,556 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-19 10:40:58 |
| 合計ジャッジ時間 | 1,339 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 1 WA * 5 |
ソースコード
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
using namespace std;
#define Would
#define you
bool prime(int n) {
for (int i = 2; i < sqrt(n); ++i) {
if (n%i != 0) {
return false;
}
}
return true;
}
int ans;
int main() {
int n;
cin >> n;
for (int i = 2; i <= n; ++i) {
if (i == 2) { ans += i; }
if (prime(i)) { ans += i; }
}
cout << ans << endl;
}