結果

問題 No.890 移調の限られた旋法
ユーザー tempura_pptempura_pp
提出日時 2019-09-20 21:51:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,801 bytes
コンパイル時間 1,159 ms
コンパイル使用メモリ 101,648 KB
実行使用メモリ 38,464 KB
最終ジャッジ日時 2023-10-12 18:50:50
合計ジャッジ時間 3,557 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 WA -
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,352 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 WA -
testcase_14 AC 79 ms
38,068 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 26 ms
14,812 KB
testcase_21 AC 6 ms
5,516 KB
testcase_22 AC 56 ms
29,960 KB
testcase_23 AC 72 ms
36,028 KB
testcase_24 AC 39 ms
21,980 KB
testcase_25 AC 10 ms
7,664 KB
testcase_26 WA -
testcase_27 AC 73 ms
37,412 KB
testcase_28 AC 46 ms
25,164 KB
testcase_29 AC 29 ms
17,608 KB
testcase_30 AC 69 ms
34,904 KB
testcase_31 AC 37 ms
20,928 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 68 ms
34,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


vector<ll> inv,fact,invfact;
void mod_build(int n=101010){
    fact.resize(n+1);
    inv.resize(n+1);
    invfact.resize(n+1);
    fact[0]=inv[0]=invfact[0]=1;
    inv[1]=1;
    rep(i,n){
        fact[i+1]=fact[i]*(i+1)%mod;
        if(i>0)inv[i+1]=mod-inv[mod%(i+1)]*(mod/(i+1))%mod;
        invfact[i+1]=invfact[i]*inv[i+1]%mod;
    }
}
ll perm(int n,int k){
    if(n<0||k<0||k>n)return 0;
    return fact[n]*invfact[n-k]%mod;
}
ll comb(int n,int k){
    if(n<0||k<0||k>n)return 0;
    return (fact[n]*invfact[n-k]%mod)*invfact[k]%mod;
}
ll powmod(ll n,ll k){
    k%=mod-1;
    if(k<0)k+=mod-1;
    ll ret=1;
    while(k){
        if(k&1)ret=ret*n%mod;
        n=n*n%mod;
        k>>=1;
    }
    return ret;
}
int main(){
    int n,k;
    cin>>n>>k;
    mod_build(n+5);
    vector<ll>  res(n+1);
    REP(i,2,n){
        if(k%i==0&&n%i==0){
            res[n/i]=comb(n/i,k/i);
        }
    }
    vector<int> used(n+1,false);
    used[0]=used[1]=1;
    rep(i,n+1){
        if(used[i])continue;
        for(int j = 2*i;j<=n;j+=i){
            used[j]=1;
        }
        for(int j = 1;i*j<=n;j++){
            res[i*j]+=mod-res[j];
            res[i*j]%=mod;
        }
    }
    ll ans = 0;
    REP(i,2,n){
        if(k%i==0&&n%i==0){
            ans+=res[n/i];
        }
    }
    cout<<ans%mod<<endl;
    return 0;
}
0