結果
問題 | No.289 数字を全て足そう |
ユーザー |
![]() |
提出日時 | 2017-06-04 00:50:35 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 470 bytes |
コンパイル時間 | 583 ms |
コンパイル使用メモリ | 62,076 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-22 04:40:22 |
合計ジャッジ時間 | 1,585 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | WA * 21 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:22:20: warning: ‘ans’ may be used uninitialized in this function [-Wmaybe-uninitialized] 22 | cout << ans << "\n"; | ^~~~
ソースコード
#include <iostream> #include <vector> #include <string> #include <stdexcept> using namespace std; int main() { string s,S; vector<long> list; int ans; cin >> s; for(long i = 0; i < s.size(); i++){ try { list.push_back(stoi(s.substr(i,1))); } catch (const std::invalid_argument& e) { } } for(int i = 0; i < list.size(); i++){ ans += list[i]; } cout << ans << "\n"; return 0; }