結果

問題 No.917 Make One With GCD
ユーザー tanon710tanon710
提出日時 2020-05-04 21:30:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 724 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 86,812 KB
実行使用メモリ 77,148 KB
最終ジャッジ日時 2023-09-06 16:48:57
合計ジャッジ時間 4,729 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
76,708 KB
testcase_01 AC 73 ms
71,372 KB
testcase_02 AC 70 ms
71,264 KB
testcase_03 AC 71 ms
71,056 KB
testcase_04 AC 71 ms
70,912 KB
testcase_05 AC 70 ms
70,792 KB
testcase_06 AC 107 ms
76,760 KB
testcase_07 AC 100 ms
77,100 KB
testcase_08 AC 78 ms
76,768 KB
testcase_09 AC 92 ms
76,864 KB
testcase_10 AC 92 ms
77,148 KB
testcase_11 AC 94 ms
76,808 KB
testcase_12 AC 97 ms
76,816 KB
testcase_13 AC 93 ms
76,788 KB
testcase_14 AC 91 ms
76,832 KB
testcase_15 AC 93 ms
77,096 KB
testcase_16 AC 92 ms
77,064 KB
testcase_17 AC 76 ms
75,376 KB
testcase_18 AC 80 ms
75,740 KB
testcase_19 AC 75 ms
75,376 KB
testcase_20 AC 81 ms
75,212 KB
testcase_21 AC 82 ms
75,908 KB
testcase_22 AC 82 ms
76,204 KB
testcase_23 AC 85 ms
76,824 KB
testcase_24 AC 81 ms
75,868 KB
testcase_25 AC 88 ms
76,728 KB
testcase_26 AC 77 ms
75,676 KB
testcase_27 AC 75 ms
71,464 KB
testcase_28 AC 74 ms
71,096 KB
testcase_29 AC 77 ms
71,688 KB
testcase_30 AC 80 ms
75,424 KB
testcase_31 AC 77 ms
71,388 KB
testcase_32 AC 81 ms
75,376 KB
testcase_33 AC 79 ms
75,424 KB
testcase_34 AC 75 ms
71,596 KB
testcase_35 AC 78 ms
75,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def primes(n):
    ret=[]
    for i in range(2,int(n**0.5)+1):
        if n%i==0:
            ret.append(i)
        while n%i==0:
            n//=i
    if n!=1:
        ret.append(n)
    return ret

n=int(input())
arr=list(map(int,input().split()))
ans=2**n-1
for i in range(n):
    cand=primes(arr[i])
    for f in range(1,2**len(cand)):
        flag=format(f,'b')
        flag='0'*(len(cand)-len(flag))+flag
        tmp=1
        for k in range(len(cand)):
            if flag[k]=='1':
                tmp*=cand[k]
        cnt=0
        for j in range(i+1,n):
            if arr[j]%tmp==0:
                cnt+=1
        if flag.count('1')%2==0:
            ans+=2**cnt
        else:
            ans-=2**cnt
print(ans)    
0