結果

問題 No.1164 GCD Products hard
ユーザー tonegawatonegawa
提出日時 2020-08-15 12:17:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 843 bytes
コンパイル時間 937 ms
コンパイル使用メモリ 74,340 KB
実行使用メモリ 86,784 KB
最終ジャッジ日時 2024-04-19 00:39:30
合計ジャッジ時間 51,299 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,126 ms
57,472 KB
testcase_01 TLE -
testcase_02 AC 1,823 ms
48,000 KB
testcase_03 AC 489 ms
18,688 KB
testcase_04 AC 488 ms
19,712 KB
testcase_05 AC 2,222 ms
56,576 KB
testcase_06 TLE -
testcase_07 TLE -
testcase_08 TLE -
testcase_09 AC 1,757 ms
49,920 KB
testcase_10 AC 477 ms
17,280 KB
testcase_11 AC 1,975 ms
52,864 KB
testcase_12 TLE -
testcase_13 AC 1,511 ms
41,856 KB
testcase_14 AC 1,598 ms
49,536 KB
testcase_15 TLE -
testcase_16 AC 1,803 ms
53,632 KB
testcase_17 AC 2,167 ms
54,912 KB
testcase_18 AC 1,871 ms
50,560 KB
testcase_19 AC 534 ms
20,864 KB
testcase_20 AC 911 ms
28,800 KB
testcase_21 TLE -
testcase_22 AC 2 ms
5,376 KB
testcase_23 TLE -
testcase_24 TLE -
testcase_25 AC 2 ms
6,940 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 2 ms
6,944 KB
testcase_28 AC 1 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <iostream>
#include <vector>
#define vll vector<ll>
using namespace std;
typedef long long int ll;
#define P 1000000007
#define Q 1000000006

int main() {
  ll a, b, n, ans = 1;
  scanf("%lld %lld %lld", &a, &b, &n);
  a--;
  ll cnt[b+1];
  ll ret, num, x;
  for(int g=b;g>=2;g--){
    ll tmp = b/g - a/g;
    ret = 1, num = tmp, x = n;
    for(;x;){
      if(x&1) ret = (ret*num)%Q;
      num=(num*num)%Q;
      x>>=1;
    }
    cnt[g] = ret;
    for(int k=2*g;k<=b;k+=g) cnt[g] -= cnt[k];
    ll t = abs(cnt[g])/Q + 1;
    cnt[g] = (cnt[g] + t*Q)%Q;
    ret = 1, num = g, x = cnt[g];
    for(;x;){
      if(x&1) ret = (ret*num)%P;
      num=(num*num)%P;
      x>>=1;
    }
    ans = (ans * ret)%P;
  }

  printf("%lld\n", ans);
}
0