結果

問題 No.1747 Many Formulae 2
ユーザー ああいいああいい
提出日時 2022-01-20 22:06:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 121 ms / 2,000 ms
コード長 737 bytes
コンパイル時間 591 ms
コンパイル使用メモリ 87,296 KB
実行使用メモリ 96,060 KB
最終ジャッジ日時 2023-08-15 22:18:25
合計ジャッジ時間 4,096 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
95,824 KB
testcase_01 AC 115 ms
95,568 KB
testcase_02 AC 121 ms
96,060 KB
testcase_03 AC 115 ms
95,600 KB
testcase_04 AC 115 ms
95,648 KB
testcase_05 AC 112 ms
95,792 KB
testcase_06 AC 111 ms
95,728 KB
testcase_07 AC 119 ms
96,036 KB
testcase_08 AC 116 ms
95,756 KB
testcase_09 AC 116 ms
95,544 KB
testcase_10 AC 119 ms
95,576 KB
testcase_11 AC 118 ms
95,740 KB
testcase_12 AC 114 ms
95,764 KB
testcase_13 AC 114 ms
95,756 KB
testcase_14 AC 113 ms
95,464 KB
testcase_15 AC 119 ms
96,028 KB
testcase_16 AC 118 ms
96,048 KB
testcase_17 AC 120 ms
95,696 KB
testcase_18 AC 118 ms
95,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input()
l = list(map(int,list(S)))

C = 10 ** 6
dat = [0] * C

prime = set()
for i in range(2,C):
    if dat[i] == 0:
        prime.add(i)
        for j in range(2 * i,C,i):
            dat[j] = 1
import sys
if len(S) == 1:
    if int(S) in prime:
        print(1)
    else:
        print(0)
    exit()
def check(x):
    i = 2
    while i * i <= x:
        if x % i == 0:
            return False
        i += 1
    return True

N = len(S) - 1
ans = 0
for bit in range(1 << N):
    Sum = 0
    now = l[0]
    for j in range(N):
        mask = 1 << j
        if mask & bit:
            Sum += now
            now = l[j+1]
        else:
            now = now * 10 + l[j+1]
    Sum += now
    if check(Sum):
        ans += 1
print(ans)
0