結果
| 問題 |
No.1168 Digit Sum Sequence
|
| コンテスト | |
| ユーザー |
faux
|
| 提出日時 | 2020-08-18 08:00:07 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 1,050 bytes |
| コンパイル時間 | 2,166 ms |
| コンパイル使用メモリ | 192,996 KB |
| 最終ジャッジ日時 | 2025-01-13 02:52:07 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 29 |
ソースコード
#include <bits/stdc++.h>
#define fi first
#define se second
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'
#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)
template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (b < a) a = b; }
using ll = long long;
using ld = long double;
using namespace std;
constexpr ll MOD = 1000000007;
signed main()
{
cout << fixed << setprecision(20);
ios::sync_with_stdio(false);
cin.tie(0);
int n; cin >> n;
auto f = [&](int x) {
int res = 0;
while (x) {
res += x % 10;
x /= 10;
}
return res;
};
while (true) {
int keta = si(to_string(n));
if (keta == 1) {
cout << n << endl;
return (0);
}
n = f(n);
}
return (0);
}
faux