UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#202772#3548. powqiuqiu1002ms1196kbC++11389b2024-02-17 09:05:482024-02-17 13:13:42

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
int a,b,p;
int mu(int a,int b){
	int ans=0;
	while(b){
		if(b&1) ans+=a,ans%=p;
		a=a<<1;a%=p;
		b>>=1;
	}
	return ans;
}
int qow(int a,int b){
	int ans=1;
	while(b){
		if(b&1) ans=mu(ans,a);
		a=mu(a,a);
		b>>=1;
	}
	return ans;
}
signed main()
{
	cin>>a>>b>>p;
	cout<<qow(a,b);
	return 0;
}

Details

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

Test #1:

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

input:

68331 68573 998244352

output:

293741275

result:

ok single line: '293741275'

Test #2:

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

input:

492633589920418497 614936933939541807 998244352

output:

396003649

result:

ok single line: '396003649'

Test #3:

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

input:

714847614091941559 437720336074058655 998244352

output:

55508487

result:

ok single line: '55508487'

Test #4:

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

input:

795761552677473363 996235504316926809 998244352

output:

83343219

result:

ok single line: '83343219'

Test #5:

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

input:

922775944742094083 738364982231145619 722765401220272391

output:

614037901234556929

result:

ok single line: '614037901234556929'

Test #6:

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

input:

855579180739012013 573801220305525717 419267732261406547

output:

71485526853465542

result:

ok single line: '71485526853465542'

Test #7:

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

input:

795120597224342033 671653932363513029 610090323098396995

output:

164343717906310328

result:

ok single line: '164343717906310328'

Test #8:

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

input:

978999426791571589 588625801826887893 799576868810095781

output:

442564150938766117

result:

ok single line: '442564150938766117'

Test #9:

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

input:

454990929271076423 687063077602980771 371223928370355377

output:

110567687898242288

result:

ok single line: '110567687898242288'

Test #10:

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

input:

502048631939309301 939481413902908773 595069909588590251

output:

200773774138946921

result:

ok single line: '200773774138946921'