結果

問題 No.890 移調の限られた旋法
ユーザー 37zigen37zigen
提出日時 2019-09-21 05:23:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 946 bytes
コンパイル時間 991 ms
コンパイル使用メモリ 75,640 KB
実行使用メモリ 33,464 KB
最終ジャッジ日時 2023-10-14 09:49:39
合計ジャッジ時間 4,721 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
29,684 KB
testcase_01 AC 42 ms
29,560 KB
testcase_02 AC 41 ms
29,720 KB
testcase_03 AC 41 ms
29,712 KB
testcase_04 AC 41 ms
29,680 KB
testcase_05 AC 41 ms
29,756 KB
testcase_06 AC 41 ms
29,680 KB
testcase_07 AC 40 ms
29,544 KB
testcase_08 AC 41 ms
29,764 KB
testcase_09 AC 41 ms
29,812 KB
testcase_10 AC 41 ms
29,688 KB
testcase_11 AC 40 ms
29,720 KB
testcase_12 AC 41 ms
29,684 KB
testcase_13 WA -
testcase_14 AC 53 ms
33,464 KB
testcase_15 AC 56 ms
33,324 KB
testcase_16 AC 57 ms
33,124 KB
testcase_17 AC 54 ms
32,912 KB
testcase_18 AC 58 ms
32,716 KB
testcase_19 AC 49 ms
31,184 KB
testcase_20 AC 44 ms
30,480 KB
testcase_21 AC 42 ms
29,792 KB
testcase_22 AC 52 ms
32,468 KB
testcase_23 AC 51 ms
33,108 KB
testcase_24 AC 49 ms
31,340 KB
testcase_25 AC 42 ms
29,576 KB
testcase_26 AC 56 ms
33,056 KB
testcase_27 AC 53 ms
32,940 KB
testcase_28 AC 48 ms
31,720 KB
testcase_29 AC 47 ms
31,112 KB
testcase_30 AC 57 ms
32,792 KB
testcase_31 AC 49 ms
31,312 KB
testcase_32 AC 60 ms
32,416 KB
testcase_33 AC 57 ms
32,836 KB
testcase_34 AC 53 ms
32,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

const long long MOD=(long long)1e9+7;
const long long MAXN=1123456;
long long fac[MAXN];
long long ifac[MAXN];
long long inv[MAXN];

long long comb(long long n, long long k) {
  return fac[n]*ifac[k]%MOD*ifac[n-k]%MOD;
}

int main() {
  fac[0]=fac[1]=ifac[0]=ifac[1]=inv[0]=inv[1]=1;
  for (int i=2;i<MAXN;++i) {
    fac[i]=i*fac[i-1]%MOD;
  }
  for (int i=2;i<MAXN;++i) {
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
  }
  for (int i=1;i<MAXN;++i) {
    ifac[i]=inv[i]*ifac[i-1]%MOD;
  }
  long long N, K;
  std::cin>>N;
  std::cin>>K;
  long long ans=0;
  std::vector<int> cnt(N, 0);
  for (long long i=2;i<=N;++i) {//i-fold symmetry
    if (K%i!=0) continue;
    if (N%i!=0) continue;
    for (int j=i*2;j<N;j+=i) {
      cnt[j]=(cnt[j]+1-cnt[i])%MOD;
    }
    ans=(ans+(1-cnt[i])*comb(N/i, K/i)%MOD+MOD)%MOD;
  }
  std::cout<<ans<<std::endl;
  return 0;
}
0