結果

問題 No.890 移調の限られた旋法
ユーザー convexineqconvexineq
提出日時 2019-09-20 22:08:48
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 1,145 bytes
コンパイル時間 107 ms
コンパイル使用メモリ 11,000 KB
実行使用メモリ 19,904 KB
最終ジャッジ日時 2023-10-12 19:27:48
合計ジャッジ時間 7,037 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 149 ms
19,816 KB
testcase_01 AC 146 ms
19,812 KB
testcase_02 AC 154 ms
19,808 KB
testcase_03 AC 143 ms
19,732 KB
testcase_04 AC 144 ms
19,784 KB
testcase_05 AC 147 ms
19,792 KB
testcase_06 AC 145 ms
19,780 KB
testcase_07 AC 143 ms
19,848 KB
testcase_08 AC 146 ms
19,760 KB
testcase_09 AC 149 ms
19,844 KB
testcase_10 AC 149 ms
19,784 KB
testcase_11 AC 149 ms
19,784 KB
testcase_12 AC 145 ms
19,896 KB
testcase_13 RE -
testcase_14 AC 143 ms
19,724 KB
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 149 ms
19,892 KB
testcase_21 AC 144 ms
19,760 KB
testcase_22 RE -
testcase_23 AC 147 ms
19,884 KB
testcase_24 RE -
testcase_25 AC 148 ms
19,768 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 AC 147 ms
19,800 KB
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

SIZE=100000; 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]

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





0