結果
| 問題 |
No.1168 Digit Sum Sequence
|
| コンテスト | |
| ユーザー |
ruase_
|
| 提出日時 | 2025-08-15 00:20:12 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 406 bytes |
| コンパイル時間 | 1,034 ms |
| コンパイル使用メモリ | 83,760 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-08-15 00:20:15 |
| 合計ジャッジ時間 | 2,315 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 29 |
ソースコード
#include <iostream>
#include <sstream>
using namespace std;
int calc(string s)
{
int ans = 0;
for (int i = 0; i < s.length(); i++) {
int num = (int)(s[i] - '0');
ans += num;
}
return ans;
}
int main()
{
string a;
cin >> a;
int ans;
ans = calc(a);
for (int i = 1 ; i < 100; i++) {
ans = calc(to_string(ans));
}
cout << ans << endl;
}
ruase_