結果

問題 No.1747 Many Formulae 2
ユーザー DrDrpilotDrDrpilot
提出日時 2022-01-18 16:35:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 568 bytes
コンパイル時間 701 ms
コンパイル使用メモリ 87,252 KB
実行使用メモリ 76,740 KB
最終ジャッジ日時 2023-08-15 07:30:42
合計ジャッジ時間 3,214 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,312 KB
testcase_01 AC 72 ms
71,428 KB
testcase_02 AC 83 ms
76,740 KB
testcase_03 AC 77 ms
71,408 KB
testcase_04 AC 74 ms
71,476 KB
testcase_05 AC 73 ms
71,512 KB
testcase_06 AC 74 ms
71,452 KB
testcase_07 AC 79 ms
76,564 KB
testcase_08 AC 71 ms
71,456 KB
testcase_09 AC 73 ms
71,420 KB
testcase_10 AC 72 ms
71,400 KB
testcase_11 AC 72 ms
71,596 KB
testcase_12 AC 72 ms
71,472 KB
testcase_13 AC 72 ms
71,456 KB
testcase_14 AC 73 ms
71,500 KB
testcase_15 AC 85 ms
76,660 KB
testcase_16 AC 81 ms
76,544 KB
testcase_17 AC 72 ms
71,220 KB
testcase_18 AC 72 ms
71,076 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
from itertools import product
def isprime(n):
    if n < 2:
        return False
    if n == 2:
        return True
    if n % 2 == 0:
        return False
    for i in range(3, int(math.sqrt(n)) + 1, 2):
        if n % i == 0: return False
    return True
s=input()
cnt=0
for bit in product(range(2),repeat=len(s)-1):
    tmp=0
    now=int(s[0])
    for i in range(len(s)-1):
        if bit[i]==0:
            now=now*10+int(s[i+1])
        else:
            tmp+=now
            now=int(s[i+1])
    tmp+=now
    if isprime(tmp):
        cnt+=1
print(cnt)
0