社区讨论

94pts #5 WA 求调

P1593因子和参与者 1已保存回复 0

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
0 条
当前快照
1 份
快照标识符
@m28ybm9w
此快照首次捕获于
2024/10/14 19:49
去年
此快照最后确认于
2025/11/04 17:12
4 个月前
查看原帖
CPP
#include <bits/stdc++.h>
using namespace std;

char *p1, *p2, buf[1000000];
#define nc() (p1==p2 && (p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++)
inline int rd() 
{
	int x = 0, f = 1; char c = nc();
	while (c < 48 || c > 57) f = c == 47 ? -1 : 1, c = nc();
	while (c >= 48 && c <= 57) x = x * 10 + c - 48, c = nc();
	return x * f; 
}

#define int long long
#define M 9901
int p[50000005], t[50000005], res = 1;

int qpow(int x, int y) 
{
	if (!y || x == 1) return 1;
	if (y == 1) return x;
	else if (y & 1) {
		int q = qpow(x, y/2)%M;
		return q*q*x%M;
	}
	else {
		int q = qpow(x, y/2)%M;
		return q*q%M;
	}
}

signed main() 
{
//	freopen("P1593.txt", "r", stdin);
	int a = rd(), b = rd(), c = 0, aa = a; //printf("%lld\n", qpow(2, 63));
	for (int x = 2; x <= a; ++x) {
		if (!(aa%x)) {
			p[++c] = x;
			while (!(aa%x) && aa) { //for (int i = 1; i <= c; ++i) printf("%d %d\n", p[i], t[i]); 
				aa /= x;
				++t[c];
			}
		}
	}
//	for (int i = 1; i <= c; ++i) printf("%d %d\n", p[i], t[i]); 
	for (int i = 1; i <= c; ++i) res *= p[i] % M != 1? 
									((qpow(p[i]%M, b*t[i]+1)-1) * qpow((p[i]-1)%M, M-2)) % M : 
									(1 + b*t[i]) % M; //printf("%d ", qpow(p[i], b*t[i]+1)); 
	printf("%d", (res%M+M)%M);
	return 0;
}

回复

0 条回复,欢迎继续交流。

正在加载回复...