結果

問題 No.1747 Many Formulae 2
ユーザー kohei2019
提出日時 2023-06-13 00:31:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 720 bytes
コンパイル時間 502 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 70,528 KB
最終ジャッジ日時 2024-06-11 23:56:53
合計ジャッジ時間 2,022 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

def factorization(N):#素因数分解√N
    arr = []
    temp = N
    for i in range(2, int(-(-N**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([N, 1])
    return arr #[素因数、個数]

S = list(input())
if S == ['1']:
    print(0)
    exit()
Np = len(S)-1
cnt = 0
for i in range(2**Np):
    ls = [S[0]]
    for j in range(Np):
        if (i >> j) & 1:
            ls.append('+')
        ls.append(S[1+j])
    ar = factorization(eval(''.join(ls)))
    if len(ar) == 1 and ar[0][1]==1:
        cnt += 1
print(cnt)

0