結果

問題 No.1747 Many Formulae 2
ユーザー lloyzlloyz
提出日時 2021-11-19 21:33:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 587 bytes
コンパイル時間 351 ms
コンパイル使用メモリ 87,004 KB
実行使用メモリ 76,760 KB
最終ジャッジ日時 2023-08-30 07:34:29
合計ジャッジ時間 2,705 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,524 KB
testcase_01 AC 69 ms
71,444 KB
testcase_02 AC 80 ms
76,760 KB
testcase_03 AC 71 ms
71,192 KB
testcase_04 AC 73 ms
71,244 KB
testcase_05 AC 73 ms
71,076 KB
testcase_06 AC 70 ms
71,244 KB
testcase_07 AC 76 ms
76,512 KB
testcase_08 AC 68 ms
71,272 KB
testcase_09 AC 67 ms
71,272 KB
testcase_10 AC 68 ms
71,520 KB
testcase_11 AC 69 ms
71,388 KB
testcase_12 AC 69 ms
71,272 KB
testcase_13 AC 68 ms
71,456 KB
testcase_14 AC 70 ms
71,408 KB
testcase_15 AC 84 ms
76,676 KB
testcase_16 AC 82 ms
76,644 KB
testcase_17 AC 70 ms
71,144 KB
testcase_18 AC 68 ms
71,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input()

n = len(S)
if n == 1:
    if S == '2' or S == '3' or S == '5' or S == '7':
        print(1)
    else:
        print(0)
    exit()

n -= 1
ans = 0
for bit in range(1 << n):
    pre = 0
    tmp = 0
    for i in range(n):
        if (bit >> i) & 1:
            tmp += int(S[pre:i + 1])
            pre = i + 1
        if i == n - 1:
            tmp += int(S[pre:])
    flag = True
    if tmp % 2 == 0:
        continue
    f = 3
    while f * f <= tmp:
        if tmp % f == 0:
            flag = False
            break
        f += 2
    if flag:
        ans += 1
print(ans)
0