ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#202790 | #3548. pow | gzq20100819 | 100 | 1ms | 1164kb | C++11 | 374b | 2024-02-17 09:31:16 | 2024-02-17 13:14:24 |
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,p;
__int128 qpow(ll a,ll b,ll p)
{
__int128 r=1,m=a%p;
while(b)
{
if(b & 1)
r=(r*m)%p;
m=m*m%p;
b >>= 1;
}
return r;
}
void write(__int128 s)
{
if(s>9)
write(s / 10);
putchar(s%10+'0');
}
int main()
{
cin >> a >> b >> p;
write(qpow(a,b,p));
exit(0);
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 0ms
memory: 1160kb
input:
68331 68573 998244352
output:
293741275
result:
ok single line: '293741275'
Test #2:
score: 10
Accepted
time: 0ms
memory: 1160kb
input:
492633589920418497 614936933939541807 998244352
output:
396003649
result:
ok single line: '396003649'
Test #3:
score: 10
Accepted
time: 0ms
memory: 1164kb
input:
714847614091941559 437720336074058655 998244352
output:
55508487
result:
ok single line: '55508487'
Test #4:
score: 10
Accepted
time: 0ms
memory: 1160kb
input:
795761552677473363 996235504316926809 998244352
output:
83343219
result:
ok single line: '83343219'
Test #5:
score: 10
Accepted
time: 0ms
memory: 1164kb
input:
922775944742094083 738364982231145619 722765401220272391
output:
614037901234556929
result:
ok single line: '614037901234556929'
Test #6:
score: 10
Accepted
time: 0ms
memory: 1164kb
input:
855579180739012013 573801220305525717 419267732261406547
output:
71485526853465542
result:
ok single line: '71485526853465542'
Test #7:
score: 10
Accepted
time: 0ms
memory: 1160kb
input:
795120597224342033 671653932363513029 610090323098396995
output:
164343717906310328
result:
ok single line: '164343717906310328'
Test #8:
score: 10
Accepted
time: 1ms
memory: 1164kb
input:
978999426791571589 588625801826887893 799576868810095781
output:
442564150938766117
result:
ok single line: '442564150938766117'
Test #9:
score: 10
Accepted
time: 0ms
memory: 1160kb
input:
454990929271076423 687063077602980771 371223928370355377
output:
110567687898242288
result:
ok single line: '110567687898242288'
Test #10:
score: 10
Accepted
time: 0ms
memory: 1164kb
input:
502048631939309301 939481413902908773 595069909588590251
output:
200773774138946921
result:
ok single line: '200773774138946921'