結果
問題 |
No.1168 Digit Sum Sequence
|
ユーザー |
![]() |
提出日時 | 2022-11-12 03:34:11 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,363 bytes |
コンパイル時間 | 2,750 ms |
コンパイル使用メモリ | 164,572 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-13 19:39:33 |
合計ジャッジ時間 | 3,824 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 WA * 9 |
ソースコード
#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; }