結果

問題 No.890 移調の限られた旋法
ユーザー tekihei2317tekihei2317
提出日時 2019-09-21 09:19:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,073 bytes
コンパイル時間 1,717 ms
コンパイル使用メモリ 171,748 KB
実行使用メモリ 34,456 KB
最終ジャッジ日時 2023-10-17 08:11:29
合計ジャッジ時間 5,308 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
27,036 KB
testcase_01 AC 49 ms
27,036 KB
testcase_02 AC 47 ms
27,036 KB
testcase_03 AC 48 ms
27,036 KB
testcase_04 AC 49 ms
27,036 KB
testcase_05 AC 51 ms
26,984 KB
testcase_06 AC 49 ms
27,036 KB
testcase_07 AC 50 ms
27,036 KB
testcase_08 AC 49 ms
27,040 KB
testcase_09 AC 48 ms
27,040 KB
testcase_10 AC 48 ms
27,040 KB
testcase_11 AC 48 ms
27,040 KB
testcase_12 AC 51 ms
27,040 KB
testcase_13 AC 64 ms
34,456 KB
testcase_14 AC 64 ms
34,456 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 53 ms
29,380 KB
testcase_21 AC 49 ms
27,268 KB
testcase_22 AC 58 ms
32,676 KB
testcase_23 AC 62 ms
33,996 KB
testcase_24 AC 57 ms
30,896 KB
testcase_25 AC 49 ms
27,532 KB
testcase_26 AC 63 ms
34,260 KB
testcase_27 AC 61 ms
34,192 KB
testcase_28 AC 58 ms
31,424 KB
testcase_29 AC 55 ms
29,908 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 63 ms
33,468 KB
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

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;
}

vector<int> calc(int N)
{
    vector<int> res;
    for(int i=1;i*i<=N;i++) if(N%i==0){
        res.push_back(i);
        if(N/i!=i) res.push_back(N/i);
    }
    return res;
}

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

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

    vector<int> dp(N);
    int ans=0;
    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);
        }
        vector<int> divisor=calc(i);
        for(int d:divisor){
            if(d<i) dp[i]=(dp[i]-dp[d]+mod)%mod;
        }
        ans+=dp[i];
    }
    cout<<ans<<endl;
    return 0;
}
0