結果

問題 No.505 カードの数式2
ユーザー htensai
提出日時 2019-11-17 20:19:40
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 399 bytes
コンパイル時間 2,000 ms
コンパイル使用メモリ 75,192 KB
実行使用メモリ 56,008 KB
最終ジャッジ日時 2024-09-25 06:04:37
合計ジャッジ時間 6,590 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11 WA * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
 	public static void main (String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long result = 0;
		for (int i = 0; i < n; i++) {
		    int x = Math.abs(sc.nextInt());
		    if (x <= 1 || result == 0) {
		        result += x;
		    } else {
		        result *= x;
		    }
		}
		System.out.println(result);
	}
}


0