結果

問題 No.432 占い(Easy)
ユーザー YamaKasaYamaKasa
提出日時 2018-05-24 00:00:02
言語 Java19
(openjdk 21)
結果
AC  
実行時間 285 ms / 2,000 ms
コード長 919 bytes
コンパイル時間 2,282 ms
コンパイル使用メモリ 74,752 KB
実行使用メモリ 63,856 KB
最終ジャッジ日時 2023-09-11 02:03:36
合計ジャッジ時間 8,821 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
56,236 KB
testcase_01 AC 124 ms
55,956 KB
testcase_02 AC 126 ms
55,968 KB
testcase_03 AC 133 ms
56,048 KB
testcase_04 AC 148 ms
54,072 KB
testcase_05 AC 129 ms
55,824 KB
testcase_06 AC 135 ms
55,788 KB
testcase_07 AC 143 ms
56,248 KB
testcase_08 AC 130 ms
56,192 KB
testcase_09 AC 206 ms
56,556 KB
testcase_10 AC 157 ms
55,856 KB
testcase_11 AC 170 ms
57,984 KB
testcase_12 AC 284 ms
63,712 KB
testcase_13 AC 285 ms
63,628 KB
testcase_14 AC 180 ms
58,868 KB
testcase_15 AC 129 ms
55,972 KB
testcase_16 AC 128 ms
55,840 KB
testcase_17 AC 278 ms
63,856 KB
testcase_18 AC 227 ms
61,772 KB
testcase_19 AC 210 ms
60,824 KB
testcase_20 AC 175 ms
58,872 KB
testcase_21 AC 188 ms
58,880 KB
testcase_22 AC 163 ms
56,364 KB
testcase_23 AC 170 ms
56,220 KB
testcase_24 AC 209 ms
57,300 KB
testcase_25 AC 200 ms
56,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int T = scan.nextInt();
		String []S = new String[T];
		for(int i = 0; i < T; i++) {
			S[i] = scan.next();
		}
		scan.close();
		for(int i = 0; i < T; i++) {
			solve(S[i]);
		}
	}
	public static void solve(String s) {
		int l = s.length();
		if(l == 1) {
			System.out.println(s);
			return ;
		}else {
			StringBuilder sb = new StringBuilder();
			for(int i = 0; i < l - 1; i++) {
				int s1 = Integer.parseInt(s.substring(i, i + 1));
				int s2 = Integer.parseInt(s.substring(i + 1, i + 2));
				int sum = s1 + s2;
				if(sum >= 10) {
					int k1 = sum / 10;
					int k2 = sum - 10;
					int sum2 = k1 + k2;
					sb.append(Integer.toString(sum2));
				}else {
					sb.append(Integer.toString(sum));
				}
			}
			//System.out.println(sb.length());
			solve(sb.toString());

		}

	}
}
0