UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#203494#2817. 小明的计算snow_trace1000ms1240kbC++11738b2024-02-26 08:26:152024-02-26 14:00:13

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 1000000007;
int qp(int p,int q){
	int ans = 1,pro = p;
	while(q){
		if(q&1)ans = ans*pro%mod;
		pro = pro*pro%mod;q>>=1;
	}return ans;
}
int n,m;
vector<pair<int,int> >f;
signed main(){
	cin >> n >> m;
	for(int i = 1;i*i<=n;i++){
		if(n%i == 0){
			f.push_back({i,(m/i)});
			if(i*i == n)continue;
			f.push_back({n/i,(m/(n/i))});
		}
	}sort(f.begin(),f.end());
//	cout << 111 << endl;
	for(int i = (int)f.size()-1;i>=0;i--){
		for(int j = i+1;j<f.size();j++){
			if(f[j].first%f[i].first == 0){
				f[i].second-=f[j].second;
			}
		}
	}int ans = 1;
	for(auto x:f)ans = ans*qp(x.first,x.second)%mod;
	cout << ans << endl;
}

Details

小提示:点击横条可展开更详细的信息

Test #1:

score: 10
Accepted
time: 0ms
memory: 1236kb

input:

865987 941795


output:

852352201

result:

ok single line: '852352201'

Test #2:

score: 10
Accepted
time: 0ms
memory: 1236kb

input:

718079 336455


output:

866737698

result:

ok single line: '866737698'

Test #3:

score: 10
Accepted
time: 0ms
memory: 1240kb

input:

78100 231920


output:

148617020

result:

ok single line: '148617020'

Test #4:

score: 10
Accepted
time: 0ms
memory: 1236kb

input:

478780 349871


output:

627456355

result:

ok single line: '627456355'

Test #5:

score: 10
Accepted
time: 0ms
memory: 1236kb

input:

492436 177462


output:

710554997

result:

ok single line: '710554997'

Test #6:

score: 10
Accepted
time: 0ms
memory: 1240kb

input:

5498214 3423692


output:

754285740

result:

ok single line: '754285740'

Test #7:

score: 10
Accepted
time: 0ms
memory: 1236kb

input:

2257405 2442817


output:

509022777

result:

ok single line: '509022777'

Test #8:

score: 10
Accepted
time: 0ms
memory: 1240kb

input:

525133 3839557


output:

712423552

result:

ok single line: '712423552'

Test #9:

score: 10
Accepted
time: 0ms
memory: 1236kb

input:

559167069 414841373


output:

191742478

result:

ok single line: '191742478'

Test #10:

score: 10
Accepted
time: 0ms
memory: 1236kb

input:

64401879 171289385


output:

75367261

result:

ok single line: '75367261'