标签:c代码 clu problem highlight ref https 64位 scan ble
网址:https://www.acwing.com/problem/content/92/
大数乘法取模模板。
AC代码:
#include <bits/stdc++.h> using namespace std; long long add(long long a, long long b, long long p) { long long res = 0; while (b) { if (b & 1) res = (res + a) % p; a = (a * 2) % p; b >>= 1; } return res % p; } int main() { long long a, b, p; scanf("%lld%lld%lld", &a, &b, &p); printf("%lld\n", add(a, b, p)); return 0; }
标签:c代码 clu problem highlight ref https 64位 scan ble
原文地址:https://www.cnblogs.com/Aya-Uchida/p/11470212.html