結果

問題 No.1164 GCD Products hard
ユーザー kyo1kyo1
提出日時 2021-06-22 14:53:43
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 869 bytes
コンパイル時間 2,030 ms
コンパイル使用メモリ 201,128 KB
実行使用メモリ 42,244 KB
最終ジャッジ日時 2023-09-05 16:27:44
合計ジャッジ時間 48,118 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,897 ms
29,968 KB
testcase_01 AC 2,414 ms
32,772 KB
testcase_02 AC 1,597 ms
25,028 KB
testcase_03 AC 443 ms
10,912 KB
testcase_04 AC 435 ms
11,000 KB
testcase_05 AC 1,945 ms
29,620 KB
testcase_06 AC 2,440 ms
35,084 KB
testcase_07 TLE -
testcase_08 AC 2,325 ms
36,692 KB
testcase_09 AC 1,523 ms
26,368 KB
testcase_10 AC 440 ms
9,744 KB
testcase_11 AC 1,781 ms
27,656 KB
testcase_12 TLE -
testcase_13 AC 1,350 ms
21,904 KB
testcase_14 AC 1,361 ms
25,880 KB
testcase_15 TLE -
testcase_16 AC 1,610 ms
27,868 KB
testcase_17 AC 1,978 ms
28,576 KB
testcase_18 AC 1,637 ms
26,604 KB
testcase_19 AC 467 ms
11,812 KB
testcase_20 AC 824 ms
15,732 KB
testcase_21 TLE -
testcase_22 AC 2 ms
4,376 KB
testcase_23 TLE -
testcase_24 TLE -
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

constexpr int mod = 1000000007;

template <typename T>
int pow(int x, T n, int mod = std::numeric_limits<int>::max()) {
  int res = 1;
  while (n > 0) {
    if (n & 1) res = static_cast<int64_t>(res) * static_cast<int64_t>(x) % mod;
    x = static_cast<int64_t>(x) * static_cast<int64_t>(x) % mod;
    n >>= 1;
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int A, B, N;
  cin >> A >> B >> N;
  vector<int> X(B + 1, 0);
  for (int g = B; g > 0; g--) {
    int a = (A - 1) / g, b = B / g;
    X[g] = pow(b - a, N, mod - 1);
    for (int i = 2 * g; i < B + 1; i += g) {
      X[g] -= X[i];
      if (X[g] < 0) X[g] += mod - 1;
    }
  }
  int res = 1;
  for (int i = 1; i < B + 1; i++) {
    res = INT64_C(1) * res * pow(i, X[i], mod) % mod;
  }
  cout << res << '\n';
  return 0;
}
0