結果

問題 No.1164 GCD Products hard
ユーザー tonegawatonegawa
提出日時 2020-08-15 12:16:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 805 bytes
コンパイル時間 918 ms
コンパイル使用メモリ 73,568 KB
実行使用メモリ 160,160 KB
最終ジャッジ日時 2024-04-19 00:36:28
合計ジャッジ時間 45,029 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,830 ms
110,976 KB
testcase_01 AC 2,376 ms
122,896 KB
testcase_02 AC 1,571 ms
92,160 KB
testcase_03 AC 390 ms
33,920 KB
testcase_04 AC 399 ms
35,840 KB
testcase_05 AC 1,918 ms
109,440 KB
testcase_06 AC 2,370 ms
131,472 KB
testcase_07 AC 2,431 ms
138,620 KB
testcase_08 AC 2,240 ms
137,988 KB
testcase_09 AC 1,515 ms
96,384 KB
testcase_10 AC 402 ms
30,976 KB
testcase_11 AC 1,717 ms
102,400 KB
testcase_12 AC 2,429 ms
130,832 KB
testcase_13 AC 1,279 ms
79,872 KB
testcase_14 AC 1,272 ms
95,232 KB
testcase_15 TLE -
testcase_16 AC 1,547 ms
103,516 KB
testcase_17 AC 1,914 ms
106,112 KB
testcase_18 AC 1,655 ms
97,792 KB
testcase_19 AC 451 ms
37,888 KB
testcase_20 AC 776 ms
54,016 KB
testcase_21 TLE -
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2,497 ms
160,160 KB
testcase_24 TLE -
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 mp[b+1];

  ll ret, num, x;
  for(int i=0;i<=b;i++){
    ret = 1, num = i, x = n;
    for(;x;){
      if(x&1) ret = (ret*num)%Q;
      num= (num*num)%Q;
      x>>=1;
    }
    mp[i] = ret;
  }

  for(int g=b;g>=2;g--){
    ll tmp = b/g - a/g;
    cnt[g] = mp[tmp];
    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