結果
問題 | No.1168 Digit Sum Sequence |
ユーザー | hayaten |
提出日時 | 2020-08-14 21:23:22 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 480 bytes |
コンパイル時間 | 1,748 ms |
コンパイル使用メモリ | 165,052 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-10 12:43:43 |
合計ジャッジ時間 | 2,502 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 29 |
ソースコード
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define rrep(i, n) for (int i = (n - 1); i >= 0; i--) #define ALL(v) v.begin(), v.end() using namespace std; using P = pair<int, int>; typedef long long ll; ll digitsum(ll n) { ll res = 0; while(n > 0) { res += n % 10; n /= 10; } return res; } int main() { ll n; cin >> n; ll num = n; ll ans = 0; rep(i, 99) { ans = digitsum(num); num = ans; } cout << ans << endl; }