結果
| 問題 | No.713 素数の和 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-07-18 00:50:40 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 511 bytes |
| 記録 | |
| コンパイル時間 | 506 ms |
| コンパイル使用メモリ | 70,996 KB |
| 実行使用メモリ | 19,520 KB |
| 最終ジャッジ日時 | 2026-05-21 23:07:26 |
| 合計ジャッジ時間 | 7,259 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | TLE * 1 -- * 5 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:30:13: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
30 | cout << ans << endl;
| ^~~
main.cpp:25:9: note: 'ans' was declared here
25 | int ans;
| ^~~
ソースコード
#include <iostream>
using namespace std;
int getPrime(int maxInt)
{
if(maxInt == 1) return -1;
int tmp = maxInt;
bool flag = 0;
while(!flag){
if(tmp < 2) return -1;
for(int i=2; i<maxInt; --i){
if(tmp%maxInt) break;
else flag = true;
}
--tmp;
}
return tmp;
}
int main()
{
int N;
cin >> N;
int ans;
while((N = getPrime(N)) != -1){
ans +=N;
N-=1;
}
cout << ans << endl;
return 0;
}