結果

問題 No.1747 Many Formulae 2
ユーザー hirafishhirafish
提出日時 2021-11-19 22:07:13
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 817 bytes
コンパイル時間 134 ms
コンパイル使用メモリ 11,028 KB
実行使用メモリ 38,640 KB
最終ジャッジ日時 2023-08-30 08:39:19
合計ジャッジ時間 7,606 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 278 ms
38,600 KB
testcase_01 AC 279 ms
38,324 KB
testcase_02 AC 287 ms
38,400 KB
testcase_03 AC 285 ms
38,468 KB
testcase_04 AC 285 ms
38,492 KB
testcase_05 AC 278 ms
38,620 KB
testcase_06 AC 278 ms
38,316 KB
testcase_07 WA -
testcase_08 AC 277 ms
38,640 KB
testcase_09 AC 280 ms
38,520 KB
testcase_10 AC 282 ms
38,512 KB
testcase_11 AC 276 ms
38,428 KB
testcase_12 AC 273 ms
38,264 KB
testcase_13 AC 278 ms
38,480 KB
testcase_14 AC 273 ms
38,336 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 273 ms
38,376 KB
testcase_18 AC 273 ms
38,480 KB
権限があれば一括ダウンロードができます

ソースコード

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