結果

問題 No.1747 Many Formulae 2
ユーザー KudeKude
提出日時 2021-11-19 21:26:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 463 bytes
コンパイル時間 258 ms
コンパイル使用メモリ 86,744 KB
実行使用メモリ 76,776 KB
最終ジャッジ日時 2023-08-30 07:19:05
合計ジャッジ時間 2,583 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,292 KB
testcase_01 AC 69 ms
71,284 KB
testcase_02 AC 77 ms
76,576 KB
testcase_03 AC 68 ms
71,292 KB
testcase_04 AC 71 ms
75,308 KB
testcase_05 AC 69 ms
71,288 KB
testcase_06 AC 69 ms
71,372 KB
testcase_07 AC 77 ms
76,064 KB
testcase_08 AC 69 ms
71,468 KB
testcase_09 AC 70 ms
71,288 KB
testcase_10 AC 70 ms
71,328 KB
testcase_11 AC 70 ms
71,032 KB
testcase_12 AC 69 ms
71,172 KB
testcase_13 AC 70 ms
71,536 KB
testcase_14 AC 71 ms
71,472 KB
testcase_15 AC 79 ms
76,696 KB
testcase_16 AC 79 ms
76,776 KB
testcase_17 AC 68 ms
71,292 KB
testcase_18 AC 69 ms
71,512 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

s = list(map(int, input()))
n = len(s)
ans = 0
for b in range(1 << n - 1):
    x = 0
    tmp = s[0]
    for i in range(n - 1):
        if b >> i & 1:
            x += tmp
            tmp = 0
        else:
            tmp *= 10
        tmp += s[i + 1]
    x += tmp
    ans += is_prime(x)

print(ans)
0