結果

問題 No.1747 Many Formulae 2
ユーザー ああいいああいい
提出日時 2022-01-20 22:03:46
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 618 bytes
コンパイル時間 347 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 86,656 KB
最終ジャッジ日時 2024-05-03 08:42:32
合計ジャッジ時間 2,823 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
83,712 KB
testcase_01 AC 81 ms
84,480 KB
testcase_02 AC 86 ms
86,528 KB
testcase_03 AC 80 ms
84,608 KB
testcase_04 AC 86 ms
84,352 KB
testcase_05 AC 81 ms
83,968 KB
testcase_06 AC 82 ms
84,352 KB
testcase_07 AC 84 ms
86,144 KB
testcase_08 AC 80 ms
84,096 KB
testcase_09 AC 81 ms
83,968 KB
testcase_10 AC 84 ms
84,224 KB
testcase_11 AC 82 ms
84,864 KB
testcase_12 AC 83 ms
84,224 KB
testcase_13 AC 81 ms
83,968 KB
testcase_14 AC 83 ms
83,968 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 81 ms
84,608 KB
testcase_18 AC 84 ms
84,352 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()
    
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 Sum in prime:
        ans += 1
print(ans)
0