結果

問題 No.1747 Many Formulae 2
ユーザー brthyyjpbrthyyjp
提出日時 2021-11-20 00:19:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 99 ms / 2,000 ms
コード長 550 bytes
コンパイル時間 543 ms
コンパイル使用メモリ 86,948 KB
実行使用メモリ 77,132 KB
最終ジャッジ日時 2023-08-30 12:08:07
合計ジャッジ時間 3,013 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,468 KB
testcase_01 AC 76 ms
71,112 KB
testcase_02 AC 99 ms
77,132 KB
testcase_03 AC 77 ms
71,228 KB
testcase_04 AC 81 ms
75,492 KB
testcase_05 AC 77 ms
71,564 KB
testcase_06 AC 76 ms
71,740 KB
testcase_07 AC 89 ms
76,380 KB
testcase_08 AC 76 ms
71,180 KB
testcase_09 AC 77 ms
71,656 KB
testcase_10 AC 78 ms
71,400 KB
testcase_11 AC 79 ms
71,152 KB
testcase_12 AC 77 ms
71,480 KB
testcase_13 AC 76 ms
71,256 KB
testcase_14 AC 74 ms
71,332 KB
testcase_15 AC 98 ms
76,996 KB
testcase_16 AC 87 ms
76,808 KB
testcase_17 AC 76 ms
71,388 KB
testcase_18 AC 76 ms
71,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

def is_prime(n):
    if n == 1:
        return False

    for i in range(2, int(math.sqrt(n))+1):
        if n%i == 0:
            return False

    return True

s = list(str(input()))
n = len(s)
ans = 0
for i in range(1<<(n-1)):
    t = []
    for j in range(n-1):
        if (i>>j)&1:
            t.append('+')
        else:
            t.append('')
    x = []
    for j in range(n-1):
        x.append(s[j])
        x.append(t[j])
    x.append(s[-1])
    x = ''.join(x)
    x = eval(x)
    if is_prime(x):
        ans += 1
print(ans)
0