UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#203497#2817. 小明的计算Anonyme1002ms1248kbC++11885b2024-02-26 09:19:402024-02-26 14:00:23

answer

#include <bits/stdc++.h>
using namespace std;

#define QwQ330AwA return 0
#define ll long long

const int mod = 1e9 + 7;
int n, m;
vector < pair <int, int> > pos;

ll ksm(ll a, int b) {
	ll ans = 1;
	for (; b; b >>= 1, a = a * a % mod) {
		if (b & 1) ans = ans * a % mod;
	}
	return ans;
}

signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m;
	for (int i = 2; 1ll * i * i <= n; i++) {
		if (n % i == 0) {
			int cnt = 0;
			while (n % i == 0) n /= i, cnt++;
			pos.push_back({i, cnt});
		}
	}
	if (n) {
		pos.push_back({n, 1});
	}
	ll ans = 1;
	for (auto qwq : pos) {
		int x = qwq.first, y = qwq.second;
		int sum = 1;
		for (int i = 1; i <= y; i++) sum *= x;
		int lst = 0;
		for (int i = y; i >= 1; i--) {
			ans = ans * ksm(sum, m / sum - lst) % mod;
			lst = m / sum;
			sum /= x;
		}
	}
	cout << ans;
	QwQ330AwA;
}

Details

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

Test #1:

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

input:

865987 941795


output:

852352201

result:

ok single line: '852352201'

Test #2:

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

input:

718079 336455


output:

866737698

result:

ok single line: '866737698'

Test #3:

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

input:

78100 231920


output:

148617020

result:

ok single line: '148617020'

Test #4:

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

input:

478780 349871


output:

627456355

result:

ok single line: '627456355'

Test #5:

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

input:

492436 177462


output:

710554997

result:

ok single line: '710554997'

Test #6:

score: 10
Accepted
time: 1ms
memory: 1248kb

input:

5498214 3423692


output:

754285740

result:

ok single line: '754285740'

Test #7:

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

input:

2257405 2442817


output:

509022777

result:

ok single line: '509022777'

Test #8:

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

input:

525133 3839557


output:

712423552

result:

ok single line: '712423552'

Test #9:

score: 10
Accepted
time: 1ms
memory: 1244kb

input:

559167069 414841373


output:

191742478

result:

ok single line: '191742478'

Test #10:

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

input:

64401879 171289385


output:

75367261

result:

ok single line: '75367261'