結果

問題 No.890 移調の限られた旋法
ユーザー mtsdmtsd
提出日時 2019-09-20 21:55:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,891 bytes
コンパイル時間 1,114 ms
コンパイル使用メモリ 118,836 KB
実行使用メモリ 13,752 KB
最終ジャッジ日時 2023-10-12 18:57:56
合計ジャッジ時間 2,803 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
9,472 KB
testcase_01 AC 9 ms
9,288 KB
testcase_02 AC 8 ms
9,352 KB
testcase_03 AC 9 ms
9,324 KB
testcase_04 AC 9 ms
9,268 KB
testcase_05 AC 8 ms
9,292 KB
testcase_06 AC 8 ms
9,260 KB
testcase_07 AC 8 ms
9,272 KB
testcase_08 AC 8 ms
9,420 KB
testcase_09 AC 9 ms
9,352 KB
testcase_10 AC 8 ms
9,420 KB
testcase_11 AC 9 ms
9,404 KB
testcase_12 AC 8 ms
9,356 KB
testcase_13 WA -
testcase_14 AC 9 ms
9,268 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 12 ms
11,356 KB
testcase_20 AC 8 ms
9,292 KB
testcase_21 AC 8 ms
9,348 KB
testcase_22 AC 11 ms
9,356 KB
testcase_23 AC 9 ms
9,352 KB
testcase_24 AC 10 ms
9,400 KB
testcase_25 AC 9 ms
9,412 KB
testcase_26 WA -
testcase_27 AC 10 ms
9,296 KB
testcase_28 AC 9 ms
9,360 KB
testcase_29 AC 10 ms
9,276 KB
testcase_30 WA -
testcase_31 AC 12 ms
9,520 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 15 ms
11,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

template<typename T>
vector<T> divisor(T n)
{
    vector<T> res;
    for(T i=1;(long long)i*i<=n;i++){
        if(n%i==0){
            res.push_back(i);
            if(i != n/i){
                res.push_back(n/i);
            }
        }
    }
    sort(res.rbegin(),res.rend());
    return res;
}
#define MAX_N 400010
#define MOD 1000000007

int inv[MAX_N],fac[MAX_N],finv[MAX_N];

void make()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i=2;i<MAX_N;i++){
        inv[i] = MOD - (long long)inv[MOD%i] * (MOD/i) % MOD;
        fac[i] = (long long)fac[i-1] * i % MOD;
        finv[i] = (long long)finv[i-1] * inv[i] % MOD;
    }
}

int comb(int a,int b)
{
    if(a < b){
        return 0;
    }
    return fac[a] * ((long long)finv[b] * finv[a-b] % MOD) % MOD;
}
ll dp[2000000]={};
    
int main(){
    make();
    int n,k;
    cin >> n >> k;
    vector<int> res = divisor(n);
    ll sm = 0;
    for(int x:res){
        if(x==1)continue;
        if(k%x==0){
            int c = k/x;
            int p = n/x;
            dp[x] = comb(p,c);
            for(int i=x+x;i<=n;i+=x){
               dp[x] += mod-dp[i];
               dp[x] %= mod;
            }
            sm += dp[x];
            sm %= mod;
        }
    }
    cout << sm << endl;
    return 0;
}
0