結果

問題 No.890 移調の限られた旋法
ユーザー convexineqconvexineq
提出日時 2019-09-20 22:10:59
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,170 bytes
コンパイル時間 326 ms
コンパイル使用メモリ 87,296 KB
実行使用メモリ 100,324 KB
最終ジャッジ日時 2023-10-12 19:30:23
合計ジャッジ時間 7,460 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 154 ms
99,524 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 156 ms
99,440 KB
testcase_06 WA -
testcase_07 AC 153 ms
99,672 KB
testcase_08 AC 158 ms
99,512 KB
testcase_09 WA -
testcase_10 AC 154 ms
99,636 KB
testcase_11 AC 154 ms
99,440 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 151 ms
99,488 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 151 ms
99,572 KB
testcase_21 AC 149 ms
99,572 KB
testcase_22 WA -
testcase_23 AC 154 ms
99,572 KB
testcase_24 WA -
testcase_25 AC 149 ms
99,608 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 148 ms
99,804 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

SIZE=1000000; MOD=10**9+7 #998244353 #ここを変更する

SIZE += 1
inv = [0]*SIZE  # inv[j] = j^{-1} mod MOD
fac = [0]*SIZE  # fac[j] = j! mod MOD
finv = [0]*SIZE # finv[j] = (j!)^{-1} mod MOD
inv[1] = 1
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
for i in range(2,SIZE):
    inv[i] = MOD - (MOD//i)*inv[MOD%i]%MOD
    fac[i] = fac[i-1]*i%MOD
    finv[i]= finv[i-1]*inv[i]%MOD

def choose(n,r): # nCk mod MOD の計算
    if 0 <= r <= n:
        return (fac[n]*finv[r]%MOD)*finv[n-r]%MOD
    else:
        return 0
        


from math import gcd

def divisor_list(N): #約数のリスト
    if N == 1: return [1]
    res = []
    for i in range(1,N):
        if i*i >= N: break
        if N%i == 0:
            res.append(i)
            res.append(N//i)
    if i*i == N: res.append(i)
    return sorted(res)

n,k = [int(i) for i in input().split()]
g = gcd(n,k)
if g == 1:
    print(0)
    exit()


div = divisor_list(n)
div = [i for i in div if g%i==0]
d = {i:choose(n//i,k//i) for i in div}
d[1] = 0
#print(d)

for i in reversed(div):
    for j in div:
        if j%i == 0 and i != j:
            d[i] -= d[j]
            d[i] %= MOD

#print(d)
print(-d[1])





0