結果

問題 No.1168 Digit Sum Sequence
ユーザー Yahiya YusufzaiYahiya Yusufzai
提出日時 2020-08-14 22:32:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 748 bytes
コンパイル時間 1,794 ms
コンパイル使用メモリ 162,036 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-18 22:22:46
合計ジャッジ時間 2,558 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 WA -
testcase_12 AC 2 ms
5,376 KB
testcase_13 WA -
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define inf  (int)1e18
#define EPS   1e-9
#define MOD 1000000007

#define Pi 3.14159
#define rep(i,a,n) for (int i=a;i<n;i++)
#define repk(i,a,n) for(int i=a;i<=(n);i++)
#define ll  long long
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define mi map<int,int>
#define vi vector<int>
#define ml map<ll,ll>
#define umap unordered_map
using namespace std;



void sol() {
	int n; cin >> n;
	int a[1005];
	int cnt, k = 0;
	while (n > 10) {
		cnt = 0;
		while (n != 0) {
			a[cnt] = n % 10;
			n /= 10;
			cnt++;
		}
		for (int i = cnt - 1; i >= 0; --i)
			k += a[i];

		n = k;
		k = 0;
	}
	cout << n << '\n';
}

int main() {


	int t = 1;
	// cin >> t;

	while (t--) {
		sol();
	}

	return 0;
}
0