結果
| 問題 | No.713 素数の和 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-07-18 00:50:40 |
| 言語 | C++11 (gcc 15.3.0 + boost 1.92.0) |
| 結果 |
TLE
不安定
|
| 実行時間 | - |
| コード長 | 511 bytes |
| 記録 | |
| コンパイル時間 | 526 ms |
| コンパイル使用メモリ | 71,348 KB |
| 実行使用メモリ | 9,848 KB |
| 最終ジャッジ日時 | 2026-09-30 23:40:01 |
| 合計ジャッジ時間 | 11,937 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_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;
}