题解 | #快速乘#
快速乘
https://www.nowcoder.com/practice/043c66e95fe548d0b8e56c1830330f93
#include <iostream> using namespace std; int main() { int q; long long int a, b, p; cin >> q; while(q--) { cin >> a >> b >> p; // int ans = (a%p)*(b%p)%p; int t=a%p; // 注意ans的类型 long long int ans = 0; while(b--) { ans += t; } cout << ans%p << endl; } } // 64 位输出请用 printf("%lld")