mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-08 14:18:47 +00:00
90. 64位整数乘法
https://www.acwing.com/problem/content/submission/code_detail/7861200/
This commit is contained in:
parent
764424125c
commit
a1f6e8959c
21
AcWing/90/90.cpp
Normal file
21
AcWing/90/90.cpp
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
long long bintimes(long long a, long long b, long long m) {
|
||||||
|
a %= m;
|
||||||
|
long long res = 0;
|
||||||
|
while (b > 0) {
|
||||||
|
if (b & 1) res = (res + a) % m;
|
||||||
|
a = (a + a) % m;
|
||||||
|
b >>= 1;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
long long a, b, p;
|
||||||
|
cin >> a >> b >> p;
|
||||||
|
cout << bintimes(a, b, p) << endl;
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user