如果你WA35分
查看原帖
如果你WA35分
1395172
Nlu5E5Bl楼主2025/7/29 15:30

hack

3
1 1 17
1 2
1 3

在处理权值时要注意权值是质数的情况

int f1(int x){
	int res=1;
	for(int i=2;i*i<=x;i++){
		int cnt=0;
		while(x%i==0){
			x/=i;
			cnt++;
		}
		if(cnt%2!=0){
			res*=i;
		}
	}
	res *= x;
	return res;
}

在x除完后还有剩余要乘到res中(代码13行),不然x中可能会剩下大于sqrt(x)的质数

2025/7/29 15:30
加载中...