結果

問題 No.1747 Many Formulae 2
ユーザー playerplayer
提出日時 2024-01-15 02:15:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 507 bytes
コンパイル時間 453 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 64,580 KB
最終ジャッジ日時 2024-01-15 02:15:09
合計ジャッジ時間 2,734 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,588 KB
testcase_01 AC 36 ms
53,588 KB
testcase_02 AC 46 ms
62,464 KB
testcase_03 AC 36 ms
53,588 KB
testcase_04 AC 40 ms
59,756 KB
testcase_05 AC 36 ms
53,588 KB
testcase_06 AC 36 ms
53,588 KB
testcase_07 AC 44 ms
59,772 KB
testcase_08 AC 36 ms
53,588 KB
testcase_09 AC 37 ms
53,588 KB
testcase_10 AC 36 ms
53,588 KB
testcase_11 AC 37 ms
53,588 KB
testcase_12 AC 37 ms
53,588 KB
testcase_13 AC 36 ms
53,588 KB
testcase_14 AC 36 ms
53,588 KB
testcase_15 AC 52 ms
64,580 KB
testcase_16 AC 45 ms
59,772 KB
testcase_17 AC 36 ms
53,588 KB
testcase_18 AC 36 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

s = list(input())
for i in range(len(s)):
    s[i] = int(s[i])

n = len(s)
ans = 0

for i in range(1 << (n - 1)):
    num = 0
    now = s[0]
    for j in range(n - 1):
        if 1 & (i >> j) == 1:
            num += now
            now = s[j + 1]
        else:
            now *= 10
            now += s[j + 1]
    num += now
    flag = True
    for k in range(2, int(num**0.5) + 1):
        if num % k == 0:
            flag = False
            break
    if flag and num != 1:
        ans += 1

print(ans)
0