結果

問題 No.1747 Many Formulae 2
ユーザー hir355hir355
提出日時 2021-11-10 23:58:43
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 544 bytes
コンパイル時間 1,282 ms
コンパイル使用メモリ 86,864 KB
実行使用メモリ 80,332 KB
最終ジャッジ日時 2023-08-30 06:29:34
合計ジャッジ時間 2,901 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,524 KB
testcase_01 AC 68 ms
71,288 KB
testcase_02 AC 74 ms
75,952 KB
testcase_03 AC 68 ms
71,388 KB
testcase_04 AC 72 ms
75,460 KB
testcase_05 AC 69 ms
71,480 KB
testcase_06 AC 69 ms
71,192 KB
testcase_07 AC 73 ms
75,428 KB
testcase_08 AC 70 ms
71,136 KB
testcase_09 AC 69 ms
71,132 KB
testcase_10 AC 70 ms
71,280 KB
testcase_11 AC 74 ms
75,420 KB
testcase_12 AC 69 ms
71,192 KB
testcase_13 AC 69 ms
71,092 KB
testcase_14 AC 68 ms
71,384 KB
testcase_15 AC 75 ms
75,676 KB
testcase_16 AC 75 ms
75,472 KB
testcase_17 RE -
testcase_18 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        while n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

s = list(map(int, input()))
a = [(0, s[0])]
for d in s[1:]:
    tmp = []
    for p, q in a:
        tmp.append((p + q, d))
        tmp.append((p, q * 10 + d))
    a = tmp[:]
ans = 0
for p, q in tmp:
    if len(prime_factorize(p + q)) == 1:
        ans += 1
print(ans)
0