結果

問題 No.1747 Many Formulae 2
ユーザー titan23titan23
提出日時 2022-06-14 13:50:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 506 bytes
コンパイル時間 304 ms
コンパイル使用メモリ 82,404 KB
実行使用メモリ 72,040 KB
最終ジャッジ日時 2024-04-10 07:14:26
合計ジャッジ時間 2,221 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
54,280 KB
testcase_01 AC 40 ms
52,452 KB
testcase_02 AC 61 ms
70,504 KB
testcase_03 AC 37 ms
53,244 KB
testcase_04 AC 45 ms
61,440 KB
testcase_05 AC 37 ms
52,876 KB
testcase_06 AC 37 ms
52,500 KB
testcase_07 AC 53 ms
66,388 KB
testcase_08 AC 37 ms
53,692 KB
testcase_09 AC 37 ms
53,768 KB
testcase_10 AC 37 ms
53,248 KB
testcase_11 AC 39 ms
54,600 KB
testcase_12 AC 37 ms
53,360 KB
testcase_13 AC 37 ms
53,000 KB
testcase_14 AC 37 ms
52,892 KB
testcase_15 AC 62 ms
72,040 KB
testcase_16 AC 51 ms
65,588 KB
testcase_17 AC 37 ms
53,388 KB
testcase_18 AC 36 ms
52,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda: sys.stdin.readline().rstrip()

def is_prime(n: int) -> bool:
  if n == 1:
    return 0
  for i in range(2, int(n**0.5)+1):
    if n % i == 0:
      return 0 
  return 1

###############

s = input()
n = len(s)
ans = 0
for i in range(1 << (n-1)):
  seq = ''
  for j in range(n-1):
    if i >> j & 1:
      seq += '+'
    else:
      seq += ' '
  tmp = s[0]
  for i in range(n-1):
    if seq[i] != ' ':
      tmp += seq[i]
    tmp += s[i+1]
  ans += is_prime(eval(tmp))
print(ans)
0