結果

問題 No.1747 Many Formulae 2
ユーザー 👑 tamatotamato
提出日時 2021-11-19 21:24:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 696 bytes
コンパイル時間 330 ms
コンパイル使用メモリ 87,564 KB
実行使用メモリ 76,956 KB
最終ジャッジ日時 2023-08-30 07:14:03
合計ジャッジ時間 2,759 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,504 KB
testcase_01 AC 69 ms
71,516 KB
testcase_02 AC 95 ms
76,916 KB
testcase_03 AC 70 ms
71,496 KB
testcase_04 AC 76 ms
76,120 KB
testcase_05 AC 73 ms
71,436 KB
testcase_06 AC 71 ms
71,516 KB
testcase_07 AC 81 ms
76,760 KB
testcase_08 AC 70 ms
71,436 KB
testcase_09 AC 71 ms
71,664 KB
testcase_10 AC 80 ms
75,840 KB
testcase_11 AC 78 ms
75,960 KB
testcase_12 AC 72 ms
71,492 KB
testcase_13 AC 70 ms
71,716 KB
testcase_14 AC 70 ms
71,588 KB
testcase_15 AC 95 ms
76,956 KB
testcase_16 AC 82 ms
76,692 KB
testcase_17 AC 71 ms
71,644 KB
testcase_18 AC 72 ms
71,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    def is_prime(n):
        if n == 1:
            return 0
        res = 1
        for i in range(2, n-1):
            if i * i > n:
                break
            if n % i == 0:
                res = 0
        return res

    S = input().rstrip('\n')
    N = len(S)

    ans = 0
    for i in range(1 << (N - 1)):
        st = []
        for j in range(N-1):
            st.append(S[j])
            if i >> j & 1:
                st.append("+")
        st.append(S[-1])
        a = eval("".join(st))
        if is_prime(a):
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()
0