結果

問題 No.1164 GCD Products hard
ユーザー furafura
提出日時 2020-08-14 03:23:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 225 ms / 2,500 ms
コード長 926 bytes
コンパイル時間 2,456 ms
コンパイル使用メモリ 199,320 KB
実行使用メモリ 9,876 KB
最終ジャッジ日時 2024-04-18 08:26:33
合計ジャッジ時間 6,704 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 143 ms
7,960 KB
testcase_01 AC 179 ms
8,428 KB
testcase_02 AC 129 ms
7,044 KB
testcase_03 AC 45 ms
5,376 KB
testcase_04 AC 45 ms
5,376 KB
testcase_05 AC 149 ms
7,816 KB
testcase_06 AC 181 ms
8,632 KB
testcase_07 AC 182 ms
9,064 KB
testcase_08 AC 173 ms
9,064 KB
testcase_09 AC 127 ms
7,328 KB
testcase_10 AC 43 ms
5,376 KB
testcase_11 AC 137 ms
7,680 KB
testcase_12 AC 184 ms
8,608 KB
testcase_13 AC 111 ms
6,688 KB
testcase_14 AC 108 ms
7,196 KB
testcase_15 AC 186 ms
9,088 KB
testcase_16 AC 124 ms
7,644 KB
testcase_17 AC 148 ms
7,664 KB
testcase_18 AC 130 ms
7,464 KB
testcase_19 AC 48 ms
5,376 KB
testcase_20 AC 74 ms
5,592 KB
testcase_21 AC 200 ms
9,088 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 181 ms
9,876 KB
testcase_24 AC 225 ms
9,752 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

class Eratosthenes_sieve{
	vector<bool> er;
	vector<int> p;
public:
	Eratosthenes_sieve(int n):er(n+1,true){
		if(n>=0) er[0]=false;
		if(n>=1) er[1]=false;
		for(int i=2;i*i<=n;i++) if(er[i]) for(int j=i*i;j<=n;j+=i) er[j]=false;
		rep(i,n+1) if(er[i]) p.emplace_back(i);
	}

	vector<int> primes()const{ return p; }

	bool is_prime(int a)const{
		assert(a<=(int)er.size()-1);
		return a>=0 && er[a];
	}
};

const int MOD=1e9+7;

lint modpow(lint a,lint k,int m){
	lint r=1;
	for(lint x=a%m;k>0;k>>=1,x=x*x%m) if(k&1) r=r*x%m;
	return r;
}

int main(){
	int a,b,n; scanf("%d%d%d",&a,&b,&n);

	Eratosthenes_sieve E(b);

	int ans=1;
	for(auto p:E.primes()){
		lint k=0;
		for(lint q=p;q<=b;q*=p){
			k+=modpow(b/q-(a-1)/q,n,MOD-1);
		}
		k%=MOD-1;
		ans=ans*modpow(p,k,MOD)%MOD;
	}
	printf("%d\n",ans);

	return 0;
}
0