結果

問題 No.933 おまわりさんこいつです
ユーザー ks2m
提出日時 2019-11-29 22:05:04
言語 Java
(openjdk 23)
結果
AC  
実行時間 631 ms / 2,000 ms
コード長 573 bytes
コンパイル時間 2,331 ms
コンパイル使用メモリ 74,976 KB
実行使用メモリ 52,712 KB
最終ジャッジ日時 2024-11-20 22:19:05
合計ジャッジ時間 8,975 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

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