結果

問題 No.1747 Many Formulae 2
ユーザー rlangevin
提出日時 2022-12-31 19:03:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 480 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 82,424 KB
実行使用メモリ 64,552 KB
最終ジャッジ日時 2024-11-26 17:36:30
合計ジャッジ時間 2,086 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

def is_prime(n):
    if n <= 1:
        return False
    i = 2
    while i * i <= n:
        if n % i == 0:
            return False
        i += 1
    return True

S = list(input())
N = len(S) - 1

ans = 0
for i in range(1 << N):
    now = S[0]
    L = []
    for j in range(N):
        if (i >> j) & 1:
            L.append(int(now))
            now = S[j + 1]
        else:
            now += S[j + 1]
    L.append(int(now))
    if is_prime(sum(L)):
        ans += 1
print(ans)
0