結果

問題 No.432 占い(Easy)
ユーザー atkrymatkrym
提出日時 2016-10-18 18:22:17
言語 Java21
(openjdk 21)
結果
AC  
実行時間 276 ms / 2,000 ms
コード長 726 bytes
コンパイル時間 2,261 ms
コンパイル使用メモリ 74,436 KB
実行使用メモリ 47,380 KB
最終ジャッジ日時 2024-05-02 02:41:52
合計ジャッジ時間 7,882 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
41,164 KB
testcase_01 AC 118 ms
41,208 KB
testcase_02 AC 133 ms
41,232 KB
testcase_03 AC 142 ms
41,280 KB
testcase_04 AC 150 ms
41,844 KB
testcase_05 AC 139 ms
41,204 KB
testcase_06 AC 148 ms
41,392 KB
testcase_07 AC 161 ms
41,900 KB
testcase_08 AC 140 ms
41,172 KB
testcase_09 AC 217 ms
42,540 KB
testcase_10 AC 180 ms
42,132 KB
testcase_11 AC 205 ms
44,800 KB
testcase_12 AC 265 ms
47,380 KB
testcase_13 AC 265 ms
47,372 KB
testcase_14 AC 198 ms
45,128 KB
testcase_15 AC 142 ms
41,572 KB
testcase_16 AC 143 ms
41,404 KB
testcase_17 AC 276 ms
47,280 KB
testcase_18 AC 244 ms
46,552 KB
testcase_19 AC 227 ms
45,972 KB
testcase_20 AC 208 ms
45,456 KB
testcase_21 AC 198 ms
45,588 KB
testcase_22 AC 183 ms
42,152 KB
testcase_23 AC 180 ms
41,668 KB
testcase_24 AC 227 ms
42,876 KB
testcase_25 AC 219 ms
42,828 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