結果

問題 No.1747 Many Formulae 2
ユーザー hirafish
提出日時 2021-11-19 22:07:13
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 817 bytes
コンパイル時間 75 ms
コンパイル使用メモリ 12,160 KB
実行使用メモリ 38,540 KB
最終ジャッジ日時 2025-01-01 17:55:46
合計ジャッジ時間 12,234 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#わんちゃん提出後だったらnumpy使えないかな・・・
import numpy as np
from itertools import product

s = input()

def seachPrimeNum(N):
    max = int(np.sqrt(N))
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum

ss = set(seachPrimeNum(199998))

lens = len(s)
bitl = list(product([False, True], repeat=lens-1))

ans = 0
for i in range(len(bitl)):
  eval_l = []
  for j in range(lens-1):
    if bitl[i][j]:
      eval_l.append(s[j])
      eval_l.append("+")
    else:
      eval_l.append(s[j])
  
  eval_l.append(s[-1])
  if eval("".join(eval_l)) in ss:
      ans += 1

print(ans)


0