結果
| 問題 |
No.713 素数の和
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-07-18 00:50:40 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 511 bytes |
| コンパイル時間 | 529 ms |
| コンパイル使用メモリ | 54,360 KB |
| 実行使用メモリ | 16,840 KB |
| 最終ジャッジ日時 | 2024-11-27 17:41:14 |
| 合計ジャッジ時間 | 25,196 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | TLE * 3 |
| other | AC * 1 WA * 1 TLE * 4 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:30:13: warning: ‘ans’ may be used uninitialized [-Wmaybe-uninitialized]
30 | cout << ans << endl;
| ^~~
ソースコード
#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;
}