結果

問題 No.890 移調の限られた旋法
ユーザー tekihei2317tekihei2317
提出日時 2019-09-21 09:11:53
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 104 ms / 2,000 ms
コード長 919 bytes
コンパイル時間 3,519 ms
コンパイル使用メモリ 169,556 KB
実行使用メモリ 34,444 KB
最終ジャッジ日時 2023-10-17 08:04:27
合計ジャッジ時間 5,317 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
27,048 KB
testcase_01 AC 36 ms
27,048 KB
testcase_02 AC 35 ms
27,048 KB
testcase_03 AC 37 ms
27,048 KB
testcase_04 AC 36 ms
27,048 KB
testcase_05 AC 35 ms
27,004 KB
testcase_06 AC 36 ms
27,048 KB
testcase_07 AC 36 ms
27,048 KB
testcase_08 AC 37 ms
27,052 KB
testcase_09 AC 36 ms
27,048 KB
testcase_10 AC 36 ms
27,052 KB
testcase_11 AC 35 ms
27,052 KB
testcase_12 AC 36 ms
27,052 KB
testcase_13 AC 85 ms
34,444 KB
testcase_14 AC 85 ms
34,444 KB
testcase_15 AC 85 ms
34,444 KB
testcase_16 AC 86 ms
34,444 KB
testcase_17 AC 93 ms
33,720 KB
testcase_18 AC 92 ms
33,720 KB
testcase_19 AC 60 ms
30,620 KB
testcase_20 AC 51 ms
29,368 KB
testcase_21 AC 39 ms
27,256 KB
testcase_22 AC 70 ms
32,664 KB
testcase_23 AC 73 ms
33,984 KB
testcase_24 AC 62 ms
30,884 KB
testcase_25 AC 42 ms
27,520 KB
testcase_26 AC 84 ms
34,248 KB
testcase_27 AC 72 ms
34,180 KB
testcase_28 AC 63 ms
31,412 KB
testcase_29 AC 56 ms
29,896 KB
testcase_30 AC 104 ms
33,720 KB
testcase_31 AC 71 ms
30,620 KB
testcase_32 AC 99 ms
33,192 KB
testcase_33 AC 91 ms
33,456 KB
testcase_34 AC 91 ms
33,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define int long long
using namespace std;

const int mod=1e9+7;
const int sz=1000010;

int fact[sz],inv[sz],ifact[sz];
void make(){
    fact[0]=fact[1]=inv[1]=ifact[0]=ifact[1]=1;
    for(int i=2;i<sz;i++){
        fact[i]=fact[i-1]*i%mod;
        inv[i]=inv[mod%i]*(mod-mod/i)%mod;
        ifact[i]=ifact[i-1]*inv[i]%mod;
    }
}
int comb(int n,int k){
    if(n<k) return 0;
    return fact[n]*ifact[k]%mod*ifact[n-k]%mod;
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    make();
    int N,K; cin>>N>>K;

    vector<int> dp(N);
    for(int i=1;i<N;i++) if(N%i==0){
        int j=N/i;
        if(K%j==0){
            dp[i]=comb(i,K/j);
        }
    }
    int ans=0;
    for(int i=1;i<N;i++) if(N%i==0){
        ans=(ans+dp[i])%mod;
        for(int j=i*2;j<N;j+=i) if(N%j==0){
            dp[j]=(dp[j]-dp[i]+mod)%mod;
        }
    }
    cout<<ans<<endl;
    return 0;
}
0