ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#202780 | #3548. pow | Josephcheng | 100 | 2ms | 1192kb | C++11 | 495b | 2024-02-17 09:12:27 | 2024-02-17 13:14:11 |
answer
#include<bits/stdc++.h>
#define LL long long
using namespace std;
LL a,b,p;
LL quickmul(LL a,LL b)
{
if(b==1) return a%p;
if(b==0) return 0;
LL res=quickmul(a,b/2)%p;
res<<=1;
res%=p;
if(b&1) res+=a;
return res%p;
}
LL qpow(LL x,LL y)
{
if(y==1) return x%p;
if(y==0) return 1%p;
LL res=qpow(x,y/2)%p;
res=quickmul(res,res)%p;
if(y&1) res=quickmul(res,x)%p;
return res%p;
}
int main()
{
scanf("%lld%lld%lld",&a,&b,&p);
printf("%lld",qpow(a,b));
}
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: 1ms
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: 1188kb
input:
795761552677473363 996235504316926809 998244352
output:
83343219
result:
ok single line: '83343219'
Test #5:
score: 10
Accepted
time: 0ms
memory: 1192kb
input:
922775944742094083 738364982231145619 722765401220272391
output:
614037901234556929
result:
ok single line: '614037901234556929'
Test #6:
score: 10
Accepted
time: 0ms
memory: 1192kb
input:
855579180739012013 573801220305525717 419267732261406547
output:
71485526853465542
result:
ok single line: '71485526853465542'
Test #7:
score: 10
Accepted
time: 0ms
memory: 1192kb
input:
795120597224342033 671653932363513029 610090323098396995
output:
164343717906310328
result:
ok single line: '164343717906310328'
Test #8:
score: 10
Accepted
time: 1ms
memory: 1188kb
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: 1192kb
input:
502048631939309301 939481413902908773 595069909588590251
output:
200773774138946921
result:
ok single line: '200773774138946921'