社区讨论

30pts求条(玄关

P15306 『NFC-OI R1』序列玖参与者 2已保存回复 7

讨论操作

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

当前回复
7 条
当前快照
1 份
快照标识符
@mllxpfd5
此快照首次捕获于
2026/02/14 14:27
5 天前
此快照最后确认于
2026/02/17 20:00
前天
查看原帖
甚至过样例了
CPP
#include<bits/stdc++.h>
#define int unsigned long long
using namespace std;
const int N=1e5+10;
int p=998244353;
int qpow(int a,int b,int m){
	int ans=1;
	while(b>0){
		if(b%2==1){
			ans*=a;
			ans%=m;
		}
		a*=a;
		a%=m;
		b/=2;
	}
	return ans;
}
int c;
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin>>t;
	//c=qpow(6,mod-2);
	while(t--){
		int a,b,k;
		cin>>a>>b>>k;
		int d=(a*b)%p;
		int e=(qpow(3,k,p-1)+1)/2; 
		int ans=qpow(d,e,p);
		cout<<ans<<"\n";
	}
	return 0;
} 



设 e=(3^(k+1)+3)/6,d=AB
所以 ans=d^e=d^(e mod (p-1)) (mod p) 

主要考虑 e mod (p-1) 这部分怎么搞 

e=(3^k+1)/2 ,显然的,(3^k mod (p-1))+1可以被 2 整除,然后就结束了。 


回复

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

正在加载回复...