結果

問題 No.890 移調の限られた旋法
ユーザー titiatitia
提出日時 2019-09-20 23:09:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 597 ms / 2,000 ms
コード長 921 bytes
コンパイル時間 95 ms
コンパイル使用メモリ 11,028 KB
実行使用メモリ 86,960 KB
最終ジャッジ日時 2023-10-12 21:36:13
合計ジャッジ時間 22,633 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 581 ms
86,652 KB
testcase_01 AC 581 ms
86,736 KB
testcase_02 AC 584 ms
86,868 KB
testcase_03 AC 586 ms
86,808 KB
testcase_04 AC 591 ms
86,960 KB
testcase_05 AC 581 ms
86,656 KB
testcase_06 AC 585 ms
86,892 KB
testcase_07 AC 577 ms
86,860 KB
testcase_08 AC 580 ms
86,896 KB
testcase_09 AC 579 ms
86,808 KB
testcase_10 AC 581 ms
86,900 KB
testcase_11 AC 589 ms
86,664 KB
testcase_12 AC 583 ms
86,868 KB
testcase_13 AC 577 ms
86,668 KB
testcase_14 AC 573 ms
86,820 KB
testcase_15 AC 588 ms
86,660 KB
testcase_16 AC 571 ms
86,896 KB
testcase_17 AC 573 ms
86,708 KB
testcase_18 AC 570 ms
86,764 KB
testcase_19 AC 586 ms
86,960 KB
testcase_20 AC 594 ms
86,804 KB
testcase_21 AC 576 ms
86,844 KB
testcase_22 AC 575 ms
86,748 KB
testcase_23 AC 597 ms
86,864 KB
testcase_24 AC 585 ms
86,892 KB
testcase_25 AC 583 ms
86,864 KB
testcase_26 AC 577 ms
86,956 KB
testcase_27 AC 575 ms
86,752 KB
testcase_28 AC 588 ms
86,660 KB
testcase_29 AC 585 ms
86,896 KB
testcase_30 AC 573 ms
86,704 KB
testcase_31 AC 586 ms
86,748 KB
testcase_32 AC 576 ms
86,900 KB
testcase_33 AC 590 ms
86,924 KB
testcase_34 AC 580 ms
86,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K=map(int,input().split())
mod=10**9+7

import math

def fact(x):
    L=int(math.sqrt(x))

    FA=dict()

    for i in range(2,L+2):
        while x%i==0:
            FA[i]=FA.get(i,0)+1
            x=x//i

    if x!=1:
        FA[x]=FA.get(x,0)+1

    return FA


FACT=[1]
for i in range(1,10**6+1):
    FACT.append(FACT[-1]*i%mod)

FACT_INV=[pow(FACT[-1],mod-2,mod)]
for i in range(10**6,0,-1):
    FACT_INV.append(FACT_INV[-1]*i%mod)

FACT_INV.reverse()

def Combi(a,b):
    if 0<=b<=a:
        return FACT[a]*FACT_INV[b]*FACT_INV[a-b]%mod
    else:
        return 0


F1=fact(N)
F2=fact(K)

LIST=[]

for f in F1:
    if f in F2:
        LIST.append(f)

ANS=0
count=1

from itertools import combinations

for i in range(1,len(LIST)+1):
    L=list(combinations(LIST,i))
    for l in L:
        x=1
        for ls in l:
            x*=ls

        ANS=(ANS+Combi(N//x,K//x)*count)%mod

    count*=-1


print(ANS)
    

0