結果

問題 No.432 占い(Easy)
ユーザー atkrymatkrym
提出日時 2016-10-18 18:22:17
言語 Java21
(openjdk 21)
結果
AC  
実行時間 227 ms / 2,000 ms
コード長 726 bytes
コンパイル時間 2,746 ms
コンパイル使用メモリ 72,184 KB
実行使用メモリ 60,260 KB
最終ジャッジ日時 2023-08-14 14:38:59
合計ジャッジ時間 7,840 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
55,780 KB
testcase_01 AC 112 ms
55,892 KB
testcase_02 AC 110 ms
56,056 KB
testcase_03 AC 117 ms
55,764 KB
testcase_04 AC 138 ms
55,832 KB
testcase_05 AC 113 ms
55,988 KB
testcase_06 AC 125 ms
55,868 KB
testcase_07 AC 141 ms
55,976 KB
testcase_08 AC 117 ms
56,252 KB
testcase_09 AC 194 ms
54,568 KB
testcase_10 AC 138 ms
56,156 KB
testcase_11 AC 151 ms
58,520 KB
testcase_12 AC 227 ms
60,248 KB
testcase_13 AC 210 ms
60,260 KB
testcase_14 AC 152 ms
58,672 KB
testcase_15 AC 111 ms
55,988 KB
testcase_16 AC 114 ms
55,992 KB
testcase_17 AC 207 ms
60,008 KB
testcase_18 AC 203 ms
59,988 KB
testcase_19 AC 196 ms
59,204 KB
testcase_20 AC 157 ms
58,788 KB
testcase_21 AC 154 ms
58,544 KB
testcase_22 AC 146 ms
55,820 KB
testcase_23 AC 154 ms
56,212 KB
testcase_24 AC 175 ms
56,732 KB
testcase_25 AC 198 ms
57,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        int n = sc.nextInt();
        for (int i = 0;i < n;i++) {
            solve(sc.next());
        }
    }
    
    public static void solve(String s) {
        while (s.length() != 1) {
            StringBuilder sb = new StringBuilder();
            for (int i = 0;i < s.length()-1;i++) {
                int sum = Integer.valueOf(s.substring(i, i+1)) + Integer.valueOf(s.substring(i+1, i+2));
                if (sum >= 10) sum -= 9;
                sb.append(sum);
            }
            s = sb.toString();
        }
        System.out.println(s);
    }
}
0