結果

問題 No.890 移調の限られた旋法
ユーザー titiatitia
提出日時 2019-09-20 22:58:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 1,059 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 11,020 KB
実行使用メモリ 24,252 KB
最終ジャッジ日時 2023-10-12 20:53:23
合計ジャッジ時間 6,129 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
24,024 KB
testcase_01 AC 129 ms
24,200 KB
testcase_02 AC 132 ms
24,132 KB
testcase_03 AC 129 ms
24,056 KB
testcase_04 AC 130 ms
24,164 KB
testcase_05 AC 127 ms
24,204 KB
testcase_06 AC 130 ms
24,016 KB
testcase_07 AC 127 ms
24,180 KB
testcase_08 AC 128 ms
24,024 KB
testcase_09 AC 127 ms
24,076 KB
testcase_10 AC 128 ms
24,252 KB
testcase_11 AC 130 ms
24,168 KB
testcase_12 AC 131 ms
24,028 KB
testcase_13 RE -
testcase_14 AC 129 ms
24,132 KB
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 129 ms
24,020 KB
testcase_21 AC 127 ms
24,132 KB
testcase_22 RE -
testcase_23 AC 130 ms
24,136 KB
testcase_24 RE -
testcase_25 AC 129 ms
24,184 KB
testcase_26 RE -
testcase_27 AC 130 ms
24,192 KB
testcase_28 AC 130 ms
24,188 KB
testcase_29 RE -
testcase_30 RE -
testcase_31 WA -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
権限があれば一括ダウンロードができます

ソースコード

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,2*10**5+1):
    FACT.append(FACT[-1]*i%mod)

FACT_INV=[pow(FACT[-1],mod-2,mod)]
for i in range(2*10**5,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

while LIST:
    #print(LIST)

    for s in LIST:
        ANS=(ANS+Combi(N//s,K//s)*count)%mod

    if len(LIST)==1:
        break
    else:
        LIST2=[]

        for i in range(len(LIST)):
            for j in range(i+1,len(LIST)):
                if LIST[i]*LIST[j]<=N:
                    LIST2.append(LIST[i]*LIST[j])

        LIST=LIST2
        count*=-1

print(ANS)
    

0