結果

問題 No.1059 素敵な集合
ユーザー ValkyrjaValkyrja
提出日時 2020-05-23 03:31:10
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 827 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 360,136 KB
最終ジャッジ日時 2024-04-16 01:31:23
合計ジャッジ時間 22,137 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,663 ms
62,020 KB
testcase_01 AC 30 ms
10,880 KB
testcase_02 TLE -
testcase_03 AC 1,023 ms
56,652 KB
testcase_04 AC 1,000 ms
56,392 KB
testcase_05 AC 955 ms
56,520 KB
testcase_06 TLE -
testcase_07 TLE -
testcase_08 TLE -
testcase_09 AC 1,244 ms
59,656 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

l,r=map(int,input().split())
if l==1:
    print(0)
    exit()
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import minimum_spanning_tree
def make_divisors(n):
    divisors = []
    global l
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            if l<=i:
                divisors.append(i)
            if i != n // i and l<=n//i:
                divisors.append(n//i)
    return divisors
d=[]
p=[]
q=[]

for i in range(l,r+1):
    ll=make_divisors(i)
    for m in ll:
        for j in range(m,i,m):
            p.append(i)
            q.append(j)
            d.append(0)
    if i!=l:
        p.append(i)
        q.append(i-1)
        d.append(1)

n=r+1
graph=csr_matrix((d,(p,q)),shape=(n,n))
tree = minimum_spanning_tree(graph,overwrite = True).astype(int)
print(tree.sum())
0