結果

問題 No.917 Make One With GCD
ユーザー stngstng
提出日時 2022-08-14 13:52:27
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 1,049 bytes
コンパイル時間 482 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 844,332 KB
最終ジャッジ日時 2024-04-08 13:34:15
合計ジャッジ時間 3,451 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
n = int(input())
a = [int(i) for i in input().split()]

idx = n//2
a1 = a[:idx]
a2 = a[idx:]

mxa = max(a)

li1 = [0]*(mxa+1)
li1[0] = 1
li2 = [0]*(mxa+1)
li2[0] = 1

idx2 = n-idx
exit()

for i in range(2**idx):
    tmp = format(i, '0'+str(idx)+'b')
    if tmp.count("1") == 0:
        continue
    for j in range(idx):
        if tmp[j] == "1":
            gd = a1[j]
            break
    for j in range(idx):
        if tmp[j] == "1":
            gd = math.gcd(gd,a1[j])
    li1[gd] += 1

for i in range(2**idx2):
    tmp = format(i, '0'+str(idx2)+'b')
    if tmp.count("1") == 0:
        continue
    for j in range(idx2):
        if tmp[j] == "1":
            gd = a2[j]
            break
    for j in range(idx2):
        if tmp[j] == "1":
            gd = math.gcd(gd,a2[j])
    li2[gd] += 1

cnt2 = 2**idx2-1
ans = 0
ans += li2[1]
#print(ans)
ans += li1[1]*(cnt2+1)

#print(ans)

for i in range(2,mxa+1):
    tmp = i
    ct = 0
    while tmp <= mxa:
        ct += li2[tmp]
        tmp += i
    ans += li1[i]*(cnt2-ct)

print(ans)
0