結果

問題 No.1747 Many Formulae 2
ユーザー 👑 timitimi
提出日時 2021-11-19 21:36:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 785 bytes
コンパイル時間 434 ms
コンパイル使用メモリ 87,124 KB
実行使用メモリ 77,348 KB
最終ジャッジ日時 2023-08-30 07:39:37
合計ジャッジ時間 3,307 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,732 KB
testcase_01 AC 76 ms
71,488 KB
testcase_02 AC 96 ms
77,348 KB
testcase_03 AC 75 ms
71,488 KB
testcase_04 AC 77 ms
75,700 KB
testcase_05 AC 72 ms
71,704 KB
testcase_06 AC 73 ms
71,588 KB
testcase_07 AC 86 ms
77,112 KB
testcase_08 AC 75 ms
71,876 KB
testcase_09 AC 73 ms
71,608 KB
testcase_10 AC 75 ms
75,724 KB
testcase_11 AC 77 ms
75,756 KB
testcase_12 AC 71 ms
71,808 KB
testcase_13 AC 71 ms
71,888 KB
testcase_14 AC 73 ms
71,780 KB
testcase_15 AC 95 ms
77,100 KB
testcase_16 AC 85 ms
77,128 KB
testcase_17 AC 73 ms
72,028 KB
testcase_18 AC 72 ms
71,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S=input()
import itertools
A=list(itertools.product([0,1], repeat=len(S)-1))
ans=0
def factorization(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


for i in A:
    s=0
    n=int(S[0])
    for j in range(len(S)-1):
        if i[j]==1:
            n*=10
            n+=int(S[j+1])
        else:
            s+=n
            n=int(S[j+1])
    s+=n 
    if len(factorization(s))==1:
        #print(factorization(s))
        a,b=factorization(s)[0]
        if a!=1 and b==1:
            ans+=1
print(ans)
0