結果

問題 No.1168 Digit Sum Sequence
ユーザー Ryuki87241978Ryuki87241978
提出日時 2022-11-12 03:34:11
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,363 bytes
コンパイル時間 2,274 ms
コンパイル使用メモリ 130,920 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-11 20:49:06
合計ジャッジ時間 4,264 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 1 ms
4,352 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,352 KB
testcase_16 AC 2 ms
4,352 KB
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 1 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,352 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 1 ms
4,352 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 1 ms
4,348 KB
testcase_26 AC 2 ms
4,352 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 1 ms
4,348 KB
testcase_29 AC 1 ms
4,348 KB
testcase_30 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <math.h>
#include <ctype.h>
#include <numeric>
#include <stdexcept>
#include <regex>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i,x,n) for(int i=x; i<(n); ++i)
#define pie 3.1415926535897932384
#define _GLIBCXX_DEBUG
#define All(a) (a).begin(),(a).end()
#define rAll(a) (a).rbegin(),(a).rend()
#define pb push_back
#define mk make_pair
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define decimal cout << fixed << setprecision(20);
#define nextP next_permutation
#define em emplace_back
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;
const ll INF1 = 1e18;
const ll mod = 998244353;
const int INF = 100000000;

template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return 1;} return 0; }
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return 1;} return 0; }

int main() {
    
    string S;
    cin >> S;
    int ans = 0;
    while(S.size() != 1) {
        ans = 0;
        for(int i=0; i<S.size(); i++) {
            ans += S[i] - '0';
        }
        if(ans <= 9) {
            break;
        }
        S = to_string(ans);
    }
    cout << ans << endl;
    return 0;
    
}
0