結果

問題 No.1168 Digit Sum Sequence
ユーザー msm1993msm1993
提出日時 2020-09-11 16:22:15
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 327 bytes
コンパイル時間 703 ms
コンパイル使用メモリ 64,256 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-26 03:32:05
合計ジャッジ時間 2,164 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <string.h>
using namespace std;
int main()
{
	string S;
	cin>>S;
	int A=0;
	int i;
	for (int i=1;i<=100;i++){
		A=0;
		for (int j=0;j<S.size();j++){
			A+=S[j]-'0';
		}
		if (A<10){
			cout<<A<<endl;
			return 0;
		}
		char S1[100];
		sprintf(S1,"%lld",A);
		S=S1;
	}
	return 0;
}
0