結果

問題 No.1747 Many Formulae 2
ユーザー kohei2019kohei2019
提出日時 2023-06-13 00:31:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 103 ms / 2,000 ms
コード長 720 bytes
コンパイル時間 2,328 ms
コンパイル使用メモリ 86,200 KB
実行使用メモリ 76,716 KB
最終ジャッジ日時 2023-09-02 17:27:27
合計ジャッジ時間 3,368 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,632 KB
testcase_01 AC 78 ms
71,372 KB
testcase_02 AC 103 ms
76,712 KB
testcase_03 AC 74 ms
71,428 KB
testcase_04 AC 81 ms
75,664 KB
testcase_05 AC 74 ms
71,496 KB
testcase_06 AC 73 ms
71,736 KB
testcase_07 AC 85 ms
76,248 KB
testcase_08 AC 73 ms
71,384 KB
testcase_09 AC 73 ms
71,316 KB
testcase_10 AC 77 ms
75,476 KB
testcase_11 AC 79 ms
75,564 KB
testcase_12 AC 74 ms
71,244 KB
testcase_13 AC 75 ms
71,400 KB
testcase_14 AC 73 ms
71,504 KB
testcase_15 AC 100 ms
76,716 KB
testcase_16 AC 85 ms
76,652 KB
testcase_17 AC 74 ms
71,684 KB
testcase_18 AC 77 ms
71,084 KB
権限があれば一括ダウンロードができます

ソースコード

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