結果

問題 No.1168 Digit Sum Sequence
ユーザー parsee1053
提出日時 2020-08-15 23:16:45
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 528 bytes
コンパイル時間 1,970 ms
コンパイル使用メモリ 72,144 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-11 03:09:39
合計ジャッジ時間 1,804 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int calc(int n) {
  int res = 0;
  while (n) {
    res += (n % 10);
    n /= 10;
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  int ans = n;
  for (int i = 1; i < 100; ++i) {
    ans = calc(ans);
  }
  cout << ans << endl;
  return 0;
}
0