結果
| 問題 |
No.1168 Digit Sum Sequence
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-05-21 22:24:31 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 34 ms / 2,000 ms |
| コード長 | 702 bytes |
| コンパイル時間 | 2,303 ms |
| コンパイル使用メモリ | 194,156 KB |
| 最終ジャッジ日時 | 2025-01-10 13:42:49 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 29 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
/*
* @title NBase
*/
class NBase{
public:
inline static vector<long long> translate(long long X,long long N) {
assert(abs(N)>1);
vector<long long> res;
while(1) {
long long b = (X%abs(N)+abs(N)) % abs(N);
res.push_back(b);
(X -= b) /= N;
if(X==0) break;
}
return res;
}
//Digit Sum
inline static constexpr long long digit_sum(long long N, long long K) {
long long sum = 0;
for (; N > 0; N /= K) sum += N % K;
return sum;
}
};
int main() {
int N; cin >> N;
assert(1 <= N && N <= 1'000'000'000);
for(int i = 2; i <= 100; ++i) {
N = NBase::digit_sum(N,10);
}
cout << N << endl;
return 0;
}