結果

問題 No.944 煎っぞ!
ユーザー neterukunneterukun
提出日時 2019-12-09 01:17:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 97 ms / 3,000 ms
コード長 745 bytes
コンパイル時間 570 ms
コンパイル使用メモリ 86,932 KB
実行使用メモリ 89,864 KB
最終ジャッジ日時 2023-08-31 00:15:40
合計ジャッジ時間 5,218 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
89,480 KB
testcase_01 AC 90 ms
89,568 KB
testcase_02 AC 91 ms
89,588 KB
testcase_03 AC 91 ms
89,804 KB
testcase_04 AC 92 ms
89,628 KB
testcase_05 AC 90 ms
89,588 KB
testcase_06 AC 91 ms
89,720 KB
testcase_07 AC 91 ms
89,488 KB
testcase_08 AC 92 ms
89,848 KB
testcase_09 AC 89 ms
89,652 KB
testcase_10 AC 75 ms
76,876 KB
testcase_11 AC 78 ms
77,816 KB
testcase_12 AC 78 ms
76,996 KB
testcase_13 AC 71 ms
71,852 KB
testcase_14 AC 78 ms
77,940 KB
testcase_15 AC 76 ms
76,900 KB
testcase_16 AC 70 ms
71,952 KB
testcase_17 AC 71 ms
71,880 KB
testcase_18 AC 79 ms
77,852 KB
testcase_19 AC 78 ms
77,416 KB
testcase_20 AC 92 ms
89,732 KB
testcase_21 AC 91 ms
89,752 KB
testcase_22 AC 90 ms
89,696 KB
testcase_23 AC 90 ms
89,416 KB
testcase_24 AC 91 ms
89,536 KB
testcase_25 AC 91 ms
89,564 KB
testcase_26 AC 92 ms
89,436 KB
testcase_27 AC 94 ms
89,864 KB
testcase_28 AC 72 ms
71,764 KB
testcase_29 AC 74 ms
71,852 KB
testcase_30 AC 94 ms
89,732 KB
testcase_31 AC 92 ms
89,600 KB
testcase_32 AC 94 ms
89,608 KB
testcase_33 AC 96 ms
89,704 KB
testcase_34 AC 97 ms
89,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def make_divisors(n):
    """自然数nの約数を列挙したリストを出力する
    計算量: O(sqrt(N))
    入出力例: 12 -> [1, 2, 3, 4, 6, 12]
    """
    divisors = []
    for k in range(1, int(n**0.5) + 1):
        if n % k == 0:
            divisors.append(k)
            if k != n // k:
                divisors.append(n // k)
    divisors = sorted(divisors)
    return divisors


n = int(input())
a = list(map(int, input().split()))


sum_a = sum(a)
div = make_divisors(sum_a)

for num in div:
    sum_ = 0
    tmp_ans = 0
    for i in range(n):
        sum_ += a[i]
        if sum_ > num:
            break
        if sum_ == num:
            tmp_ans += 1
            sum_ = 0
    else:
        print(tmp_ans)
        exit()
0