結果

問題 No.432 占い(Easy)
ユーザー SSRS
提出日時 2020-08-07 06:43:55
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 457 bytes
コンパイル時間 549 ms
コンパイル使用メモリ 67,088 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-22 14:00:07
合計ジャッジ時間 1,439 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 2
other AC * 5 WA * 17
権限があれば一括ダウンロードができます

ソースコード

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[0] - '0';
			int b = S[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