比赛 位运算及及其应用题单 评测结果 AAAAA
题目名称 64位整数乘法 最终得分 100
用户昵称 IMZ 运行时间 0.015 s
代码语言 C++ 内存使用 3.36 MiB
提交时间 2025-01-25 14:38:24
显示代码纯文本
#include<bits/stdc++.h>
#define int long long
using namespace std;
int solve(int a,int b,int p){
    int ret=0;
    for(;b;b>>=1){
        if((b&1)==1){
            ret=(ret+a)%p;
        }
        a=2*a%p;
    }
    return ret;
}
signed main(){
    freopen("64mul.in","r",stdin);
    freopen("64mul.out","w",stdout);
    int a,b,p;
    scanf("%lld%lld%lld",&a,&b,&p);
    cout<<solve(a,b,p);
    return 0;
}