結果

問題 No.1164 GCD Products hard
ユーザー SSRSSSRS
提出日時 2021-12-19 20:40:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,179 bytes
コンパイル時間 1,541 ms
コンパイル使用メモリ 168,648 KB
実行使用メモリ 232,648 KB
最終ジャッジ日時 2023-10-13 18:59:13
合計ジャッジ時間 13,019 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long modpow(long long a, long long b){
  long long ans = 1;
  while (b > 0){
    if (b % 2 == 1){
      ans *= a;
      ans %= MOD;
    }
    a *= a;
    a %= MOD;
    b /= 2;
  }
  return ans;
}
void zeta(vector<long long> &A){
  int N = A.size();
  for (int i = 1; i < N; i++){
    for (int j = i * 2; j < N; j += i){
      A[i] += A[j];
      if (A[i] >= MOD){
        A[i] -= MOD;
      }
    }
  }
}
void mobius(vector<long long> &A){
  int N = A.size();
  for (int i = N - 1; i >= 1; i--){
    for (int j = i * 2; j < N; j += i){
      A[i] -= A[j];
      if (A[i] < 0){
        A[i] += MOD;
      }
    }
  }
}
vector<long long> gcd_convolution_pow(vector<long long> A, int K){
  int N = A.size();
  zeta(A);
  for (int i = 0; i < N; i++){
    A[i] = modpow(A[i], K);
  }
  mobius(A);
  return A;
}
int main(){
  int A, B, N;
  cin >> A >> B >> N;
  vector<long long> f(B + 1, 0);
  for (int i = A; i <= B; i++){
    f[i]++;
  }
  f = gcd_convolution_pow(f, N);
  long long ans = 1;
  for (int i = 1; i <= B; i++){
    ans *= modpow(i, f[i]);
    ans %= MOD;
  }
  cout << ans << endl;
}
0