結果
問題 |
No.289 数字を全て足そう
|
ユーザー |
![]() |
提出日時 | 2019-02-11 15:00:18 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 386 bytes |
コンパイル時間 | 1,266 ms |
コンパイル使用メモリ | 158,076 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-18 10:39:20 |
合計ジャッジ時間 | 1,946 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { // 1. 入力情報取得. string S; cin >> S; // 2. 文字列中 '0' ~ '9' の 合計. int ans = 0; for(int i = 0; i < S.size(); i++){ int c = S[i] - '0'; if(c >= 0 && c <= 9) ans += c; } // 3. 出力 ~ 後処理. cout << ans << endl; return 0; }