mirror of
https://github.com/wczffl-503/OI-Codes.git
synced 2025-07-08 02:13:51 +08:00
Upload codes: contests
This commit is contained in:
34
Luogu/P_10446_64_位整数乘法.cpp
Normal file
34
Luogu/P_10446_64_位整数乘法.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
#include <bits/stdc++.h>
|
||||
#define lo long long
|
||||
#define IMX LONG_LONG_MAX
|
||||
#define IMN LONG_LONG_MIN
|
||||
|
||||
using namespace std;
|
||||
const int N = 1e7 + 10;
|
||||
/*
|
||||
toothless. #17
|
||||
@fredcss_dev
|
||||
*/
|
||||
|
||||
lo qpow(lo a, lo b, lo p) {
|
||||
lo result = 0;
|
||||
while (b) {
|
||||
if (b & 1) {
|
||||
result += a;
|
||||
result %= p;
|
||||
}
|
||||
b >>= 1;
|
||||
a += a;
|
||||
a %= p;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
lo a, b, p;
|
||||
|
||||
signed main()
|
||||
{
|
||||
cin >> a >> b >> p;
|
||||
cout << qpow(a, b, p);
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user