結果
| 問題 | 
                            No.1164 GCD Products hard
                             | 
                    
| ユーザー | 
                             milanis48663220
                         | 
                    
| 提出日時 | 2020-08-17 01:14:37 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,746 bytes | 
| コンパイル時間 | 799 ms | 
| コンパイル使用メモリ | 86,216 KB | 
| 実行使用メモリ | 23,344 KB | 
| 最終ジャッジ日時 | 2024-10-11 10:48:19 | 
| 合計ジャッジ時間 | 13,215 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 4 WA * 23 | 
ソースコード
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
template <typename T>
T pow(T a, ll n) {
	T ans = 1;
	T tmp = a;
	for (int i = 0; i <= 60; i++) {
		ll m = (ll)1 << i;
		if (m & n) {
		ans *= tmp;
		ans %= MOD;
		}
		tmp *= tmp;
		tmp %= MOD;
	}
	return ans;
}
template <typename T>
T pow_(T a, ll n) {
	T ans = 1;
	T tmp = a;
	for (int i = 0; i <= 60; i++) {
		ll m = (ll)1 << i;
		if (m & n) {
		ans *= tmp;
		ans %= (MOD-1);
		}
		tmp *= tmp;
		tmp %= (MOD-1);
	}
	return ans;
}
bool is_prime[10000001];
vector<ll> ps;
void init(){
    for(int i = 2; i <= 10000000; i++){
        is_prime[i] = true;
    }
    for(int i = 2; i*i <= 10000000; i++){
        if(is_prime[i]){
            for(int j = 2; i*j <= 10000000; j++){
                is_prime[i*j] = false;
            }
        }
    }
    for(int i = 2; i <= 10000000; i++){
        if(is_prime[i]) ps.push_back(i);
    }
}
ll A, B, N;
// [A, B]のnで割り切れる個数
ll count(ll n){
    return B/n-(A-1)/n;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    init();
    cin >> A >> B >> N;
    ll ans = 1;
    for(ll n : ps){
        ll tmp = n;
        while(tmp <= B){
            ll c = pow_<ll>(count(tmp), N)-pow_<ll>(count(tmp*n), N);
            // ll c = pow<ll>(count(tmp), N)-pow<ll>(count(tmp*n), N);
            // if(c > 0) cout << n << ' ' << count(tmp) << ' ' << count(tmp*n) << ' ' << c << endl;
            c = (c%MOD+MOD)%MOD;
            ans *= pow<ll>(tmp, c);
            ans %= MOD;
            tmp *= n;
        }
    }
    cout << ans << endl;
}
            
            
            
        
            
milanis48663220