結果

問題 No.933 おまわりさんこいつです
ユーザー tentententen
提出日時 2020-08-26 17:15:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 659 ms / 2,000 ms
コード長 583 bytes
コンパイル時間 2,949 ms
コンパイル使用メモリ 73,732 KB
実行使用メモリ 52,056 KB
最終ジャッジ日時 2024-04-25 03:30:03
合計ジャッジ時間 10,704 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
40,940 KB
testcase_01 AC 124 ms
40,840 KB
testcase_02 AC 126 ms
40,060 KB
testcase_03 AC 114 ms
40,232 KB
testcase_04 AC 119 ms
40,624 KB
testcase_05 AC 125 ms
41,104 KB
testcase_06 AC 125 ms
41,200 KB
testcase_07 AC 125 ms
41,452 KB
testcase_08 AC 134 ms
41,564 KB
testcase_09 AC 136 ms
41,312 KB
testcase_10 AC 132 ms
41,224 KB
testcase_11 AC 155 ms
41,352 KB
testcase_12 AC 171 ms
41,928 KB
testcase_13 AC 202 ms
44,220 KB
testcase_14 AC 223 ms
45,868 KB
testcase_15 AC 263 ms
46,728 KB
testcase_16 AC 382 ms
47,352 KB
testcase_17 AC 536 ms
48,056 KB
testcase_18 AC 134 ms
41,472 KB
testcase_19 AC 545 ms
47,760 KB
testcase_20 AC 533 ms
47,760 KB
testcase_21 AC 118 ms
40,016 KB
testcase_22 AC 130 ms
41,088 KB
testcase_23 AC 645 ms
52,056 KB
testcase_24 AC 659 ms
51,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 1;
        for (int i = 0; i < n; i++) {
            ans *= getNum(sc.nextLong());
            ans = getNum(ans);
        }
        System.out.println(ans);
    }
    
    static int getNum(long x) {
        if (x < 10) {
            return (int)x;
        }
        int sum = 0;
        while (x > 0) {
            sum += (int)(x % 10);
            x /= 10;
        }
        return getNum(sum);
    }
}
0