結果

問題 No.1747 Many Formulae 2
ユーザー titiatitia
提出日時 2021-11-19 21:33:24
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 759 bytes
コンパイル時間 813 ms
コンパイル使用メモリ 86,804 KB
実行使用メモリ 89,076 KB
最終ジャッジ日時 2023-08-30 07:33:23
合計ジャッジ時間 4,209 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
88,424 KB
testcase_01 AC 111 ms
88,708 KB
testcase_02 AC 112 ms
88,716 KB
testcase_03 AC 104 ms
88,444 KB
testcase_04 AC 144 ms
88,580 KB
testcase_05 AC 100 ms
88,248 KB
testcase_06 AC 101 ms
88,472 KB
testcase_07 AC 175 ms
88,856 KB
testcase_08 AC 104 ms
88,456 KB
testcase_09 AC 105 ms
88,540 KB
testcase_10 AC 101 ms
88,368 KB
testcase_11 AC 101 ms
88,504 KB
testcase_12 AC 108 ms
88,524 KB
testcase_13 AC 103 ms
88,520 KB
testcase_14 AC 104 ms
88,504 KB
testcase_15 AC 259 ms
89,076 KB
testcase_16 AC 188 ms
88,896 KB
testcase_17 AC 102 ms
88,520 KB
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

S=input().strip()

def calc(S):
    #print("!",S)
    if len(S)==0:
        yield 0
    for i in range(1,len(S)+1):
        x=int(S[:i])
        #print("?",x,S[i:],list(calc(S[i:])))
        for j in calc(S[i:]):
            yield x+j

import math
x=10**6
L=math.floor(math.sqrt(x)) # 平方根を求める

Primelist=[i for i in range(x+1)]
Primelist[1]=0 # 1は素数でないので0にする.
 
for i in Primelist:
    if i>L:
        break
    if i==0:
        continue
    for j in range(2*i,x+1,i):
        Primelist[j]=0

Primes=[Primelist[j] for j in range(x+1) if Primelist[j]!=0]


ANS=0
for j in calc(S):
    for k in Primes:
        if j!=k and j%k==0:
            break
    else:
        ANS+=1

print(ANS)
0