結果

問題 No.1747 Many Formulae 2
ユーザー mesame3993mesame3993
提出日時 2021-11-20 00:28:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 414 bytes
コンパイル時間 2,043 ms
コンパイル使用メモリ 86,796 KB
実行使用メモリ 76,696 KB
最終ジャッジ日時 2023-08-30 12:20:46
合計ジャッジ時間 3,009 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,728 KB
testcase_01 AC 74 ms
71,824 KB
testcase_02 AC 96 ms
76,664 KB
testcase_03 AC 73 ms
71,396 KB
testcase_04 AC 79 ms
75,632 KB
testcase_05 AC 73 ms
71,900 KB
testcase_06 AC 73 ms
71,652 KB
testcase_07 AC 88 ms
76,016 KB
testcase_08 AC 74 ms
71,548 KB
testcase_09 AC 72 ms
71,892 KB
testcase_10 AC 75 ms
71,668 KB
testcase_11 AC 75 ms
71,776 KB
testcase_12 AC 73 ms
71,652 KB
testcase_13 AC 75 ms
71,784 KB
testcase_14 AC 74 ms
71,284 KB
testcase_15 AC 91 ms
76,696 KB
testcase_16 AC 85 ms
76,148 KB
testcase_17 AC 73 ms
71,668 KB
testcase_18 AC 72 ms
71,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def is_prime(n):
  if n == 1:
    return False
  limit = int(n**0.5)+1
  for i in range(2, limit):
    if n%i == 0:
      return False
  return True

def main():
  s = input()
  ans = 0
  n = len(s)
  for b in range(2**(n-1)):
    formula = []
    for i in range(n):
      formula.append(s[i])
      if i<n-1 and (b>>i)&1:
        formula.append('+')
    ans += is_prime(eval(''.join(formula)))
  print(ans)
main()
0