結果

問題 No.1164 GCD Products hard
ユーザー rlangevinrlangevin
提出日時 2023-09-10 12:32:48
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 989 bytes
コンパイル時間 6,229 ms
コンパイル使用メモリ 306,196 KB
実行使用メモリ 71,552 KB
最終ジャッジ日時 2023-09-10 12:33:06
合計ジャッジ時間 17,323 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using P = pair<int, int>;
using mint = modint1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

ll modpow(ll v, ll N, int mod){
    ll val = 1;
    ll now = v;
    rep(i, 30){
        if ((N >> i) & 1){
            val *= now;
            val %= mod;
        }
        now = now * now;
        now %= mod;
    }
    return val;
}

int main()
{
    int A, B, N;
    cin >> A >> B >> N;
    int mod = 1000000007;
    vector<ll> dp(B + 1);
    for (int i = B; i >= 1; i--){
        for (int j = 2 * i; j <= B; j += i){
            dp[i] -= dp[j];
            dp[i] = (mod - 1 + dp[i]) % (mod - 1); 
        }
        ll v = B/i - (A - 1)/i;
        dp[i] += modpow(v, N, mod - 1);
        dp[i] = (mod - 1 + dp[i]) % (mod - 1); 
    }

    mint ans = 1;
    for (int i = 1; i <= B; i++){
        ans *= mint(i).pow(dp[i]);
    }
    cout << ans.val() << endl;
}
0