結果

問題 No.1168 Digit Sum Sequence
ユーザー koutykkk
提出日時 2020-08-14 21:31:12
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 794 bytes
コンパイル時間 1,548 ms
コンパイル使用メモリ 168,680 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-10 14:13:34
合計ジャッジ時間 2,524 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//cout << fixed << setprecision();
//priority_queue<ll, vector<ll>, greater<ll>> q;
signed main(){
	ll n; cin>>n;
	ll q=99;
	while(q--){
		string s=to_string(n);
		ll cnt=0;
		rep(i,0,s.size())cnt+=(s[i]-'0');
		if(n==cnt)break;
		n=cnt;
	}
	cout<<n<<endl;
	
	
	return 0;
}
0