結果

問題 No.933 おまわりさんこいつです
ユーザー ks2m
提出日時 2019-11-29 22:04:07
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 572 bytes
コンパイル時間 2,444 ms
コンパイル使用メモリ 74,348 KB
実行使用メモリ 63,512 KB
最終ジャッジ日時 2024-11-20 22:18:48
合計ジャッジ時間 9,719 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 8 WA * 17
権限があれば一括ダウンロードができます

ソースコード

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++) {
			ans *= p[i];
			if (ans == 0) {
				System.out.println(0);
				return;
			}
			ans %= 9;
		}
		if (ans == 0) {
			System.out.println(9);
		} else {
			System.out.println(ans);
		}
	}
}
0