結果
| 問題 |
No.1168 Digit Sum Sequence
|
| コンテスト | |
| ユーザー |
iqueue02
|
| 提出日時 | 2020-08-14 21:49:49 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 405 bytes |
| コンパイル時間 | 2,427 ms |
| コンパイル使用メモリ | 191,172 KB |
| 最終ジャッジ日時 | 2025-01-12 23:39:02 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 29 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int INF = 1e9;
int main() {
int n;
cin >> n;
auto calc = [&](int m){
int res = 0;
while (m) res += m % 10, m /= 10;
return res;
};
while (n >= 10) {
n = calc(n);
}
cout << n << endl;
return 0;
}
iqueue02