結果

問題 No.1747 Many Formulae 2
ユーザー 河野竜也
提出日時 2021-12-29 21:23:44
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 329 bytes
コンパイル時間 133 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-10-04 12:58:43
合計ジャッジ時間 1,744 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

def hantei(n):
  if n<=1:
    return False
  m=int(n**0.5)
  for i in range(2,m+1):
    if n%i==0:
      return False
  return True
s=input()
n=len(s)
ans=0
for bit in range(1<<(n-1)):
  cnt=""
  for i in range(n-1):
    cnt+=s[i]
    if bit&(1<<i):
      cnt+="+"
  cnt+=s[-1]
  m=eval(cnt)
  if hantei(m):
    ans+=1
print(ans)
0