結果

問題 No.432 占い(Easy)
ユーザー SSRSSSRS
提出日時 2020-08-07 06:44:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 461 bytes
コンパイル時間 578 ms
コンパイル使用メモリ 65,656 KB
実行使用メモリ 5,036 KB
最終ジャッジ日時 2023-10-23 20:20:49
合計ジャッジ時間 1,428 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
using namespace std;
string f(string S){
	int N = S.size();
	if (N == 1){
		return S;
	} else {
		string ans;
		for (int i = 0; i < N - 1; i++){
			int a = S[i] - '0';
			int b = S[i + 1] - '0';
			if (a + b <= 9){
				ans += '0' + a + b;
			} else {
				ans += '0' + a + b - 9;
			}
		}
		return f(ans);
	}
}
int main(){
	int T;
	cin >> T;
	for (int i = 0; i < T; i++){
		string S;
		cin >> S;
		cout << f(S) << endl;
	}
}
0