結果

問題 No.1747 Many Formulae 2
ユーザー 👑 H20H20
提出日時 2021-11-19 22:09:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 498 bytes
コンパイル時間 269 ms
コンパイル使用メモリ 86,900 KB
実行使用メモリ 76,916 KB
最終ジャッジ日時 2023-08-30 08:42:46
合計ジャッジ時間 2,955 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,456 KB
testcase_01 AC 68 ms
71,392 KB
testcase_02 AC 79 ms
76,736 KB
testcase_03 AC 68 ms
71,420 KB
testcase_04 AC 76 ms
75,548 KB
testcase_05 AC 70 ms
71,328 KB
testcase_06 AC 71 ms
71,256 KB
testcase_07 AC 79 ms
76,452 KB
testcase_08 AC 67 ms
71,640 KB
testcase_09 AC 68 ms
71,572 KB
testcase_10 AC 69 ms
71,480 KB
testcase_11 AC 70 ms
71,528 KB
testcase_12 AC 68 ms
71,640 KB
testcase_13 AC 70 ms
71,280 KB
testcase_14 AC 67 ms
71,460 KB
testcase_15 AC 82 ms
76,572 KB
testcase_16 AC 80 ms
76,916 KB
testcase_17 AC 69 ms
71,384 KB
testcase_18 AC 69 ms
71,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input()


#引数nが素数かどうかを判定
def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1


cnt = 0
for i in range(2 ** (len(S)-1)):
    v = 0
    temp = int(S[0])
    for j in range(len(S)-1):
        if ((i >> j) & 1):
            v+=temp
            temp = int(S[j+1])
        else:
            temp = temp*10+int(S[j+1])
    v+=temp
    if is_prime(v):
        cnt+=1
print(cnt)
0