結果

問題 No.933 おまわりさんこいつです
ユーザー ks2mks2m
提出日時 2019-11-29 22:05:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 693 ms / 2,000 ms
コード長 573 bytes
コンパイル時間 2,240 ms
コンパイル使用メモリ 75,188 KB
実行使用メモリ 63,488 KB
最終ジャッジ日時 2024-04-30 23:38:13
合計ジャッジ時間 9,770 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
54,260 KB
testcase_01 AC 135 ms
54,084 KB
testcase_02 AC 134 ms
54,096 KB
testcase_03 AC 134 ms
54,404 KB
testcase_04 AC 137 ms
54,088 KB
testcase_05 AC 140 ms
54,252 KB
testcase_06 AC 144 ms
54,296 KB
testcase_07 AC 145 ms
54,140 KB
testcase_08 AC 148 ms
54,348 KB
testcase_09 AC 145 ms
54,248 KB
testcase_10 AC 147 ms
54,204 KB
testcase_11 AC 174 ms
54,104 KB
testcase_12 AC 188 ms
54,376 KB
testcase_13 AC 217 ms
57,132 KB
testcase_14 AC 235 ms
57,668 KB
testcase_15 AC 275 ms
58,692 KB
testcase_16 AC 427 ms
59,152 KB
testcase_17 AC 586 ms
59,392 KB
testcase_18 AC 138 ms
53,844 KB
testcase_19 AC 634 ms
59,268 KB
testcase_20 AC 570 ms
59,164 KB
testcase_21 AC 137 ms
54,144 KB
testcase_22 AC 137 ms
54,356 KB
testcase_23 AC 669 ms
62,972 KB
testcase_24 AC 693 ms
63,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] p = new long[n];
		for (int i = 0; i < p.length; i++) {
			p[i] = sc.nextLong();
		}
		sc.close();

		if (n == 0) {
			System.out.println(0);
			return;
		}

		long ans = 1;
		for (int i = 0; i < n; i++) {
			if (p[i] == 0) {
				System.out.println(0);
				return;
			}
			ans *= p[i];
			ans %= 9;
		}
		if (ans == 0) {
			System.out.println(9);
		} else {
			System.out.println(ans);
		}
	}
}
0