結果

問題 No.944 煎っぞ!
ユーザー ks2m
提出日時 2019-12-09 23:01:24
言語 Java
(openjdk 23)
結果
AC  
実行時間 223 ms / 3,000 ms
コード長 807 bytes
コンパイル時間 2,237 ms
コンパイル使用メモリ 76,256 KB
実行使用メモリ 49,920 KB
最終ジャッジ日時 2024-06-23 07:49:19
合計ジャッジ時間 9,019 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] sa = br.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		for (int i = 1; i < n; i++) {
			a[i] += a[i - 1];
		}

		label:
		for (int x = 1; x <= a[n - 1]; x++) {
			if (a[n - 1] % x == 0) {
				int m = x;
				int i = 0;
				while (m < a[n - 1]) {
					if (a[i] < m) {
						i++;
					} else if (a[i] == m) {
						i++;
						m += x;
					} else {
						continue label;
					}
				}
				System.out.println(a[n - 1] / x);
				return;
			}
		}
	}
}
0