結果

問題 No.1747 Many Formulae 2
ユーザー rlangevinrlangevin
提出日時 2022-12-31 19:03:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 480 bytes
コンパイル時間 330 ms
コンパイル使用メモリ 87,208 KB
実行使用メモリ 76,724 KB
最終ジャッジ日時 2023-08-17 18:33:07
合計ジャッジ時間 3,388 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,324 KB
testcase_01 AC 75 ms
71,304 KB
testcase_02 AC 94 ms
76,588 KB
testcase_03 AC 76 ms
71,320 KB
testcase_04 AC 76 ms
75,192 KB
testcase_05 AC 73 ms
71,288 KB
testcase_06 AC 72 ms
71,368 KB
testcase_07 AC 87 ms
76,424 KB
testcase_08 AC 75 ms
71,288 KB
testcase_09 AC 74 ms
71,324 KB
testcase_10 AC 73 ms
71,312 KB
testcase_11 AC 77 ms
71,304 KB
testcase_12 AC 74 ms
71,272 KB
testcase_13 AC 74 ms
71,000 KB
testcase_14 AC 72 ms
71,136 KB
testcase_15 AC 87 ms
76,596 KB
testcase_16 AC 86 ms
76,724 KB
testcase_17 AC 74 ms
71,004 KB
testcase_18 AC 75 ms
71,272 KB
権限があれば一括ダウンロードができます

ソースコード

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