結果

問題 No.1747 Many Formulae 2
コンテスト
ユーザー kohei2019
提出日時 2023-06-13 00:31:51
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 80 ms / 2,000 ms
+ 797µs
コード長 720 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 281 ms
コンパイル使用メモリ 96,236 KB
実行使用メモリ 84,224 KB
最終ジャッジ日時 2026-07-25 20:02:38
合計ジャッジ時間 2,811 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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