結果

問題 No.1164 GCD Products hard
ユーザー chocorusk
提出日時 2020-08-11 23:57:00
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 1,146 bytes
コンパイル時間 1,308 ms
コンパイル使用メモリ 122,496 KB
最終ジャッジ日時 2025-01-12 20:38:48
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 16 TLE * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
ll powmod(ll a, ll k, ll mod){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=mod;
        }
        ap=ap*ap;
        ap%=mod;
        k>>=1;
    }
    return ans;
}
ll inv(ll a, ll mod){
    return powmod(a, mod-2, mod);
}
ll c[10000010];
int main()
{
	int a, b, n; cin>>a>>b>>n;
	for(int d=b; d>=1; d--){
		c[d]=powmod(b/d-(a-1)/d, n, MOD-1);
		for(int i=2*d; i<=b; i+=d){
			c[d]+=MOD-1-c[i];
			if(c[d]>=MOD-1) c[d]-=(MOD-1);
		}
	}
	ll ans=1;
	for(int i=1; i<=b; i++){
		(ans*=powmod(i, c[i], MOD))%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}
0