結果

問題 No.289 数字を全て足そう
ユーザー miku39kk
提出日時 2018-01-03 21:42:02
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 592 bytes
コンパイル時間 525 ms
コンパイル使用メモリ 64,116 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-23 02:29:07
合計ジャッジ時間 1,365 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

int main() {
    int ans = 0;
    string s;
    cin >> s;
    for(int i = 0;i < s.size();i++){
        if(s[i] == '1')ans += 1;
        else if(s[i] == '2')ans += 2;
        else if(s[i] == '3')ans += 3;
        else if(s[i] == '4')ans += 4;
        else if(s[i] == '5')ans += 5;
        else if(s[i] == '6')ans += 6;
        else if(s[i] == '7')ans += 7;
        else if(s[i] == '8')ans += 8;
        else if(s[i] == '9')ans += 9;
    }
    cout << ans;
    
    return 0;
}
0