AcWing
  • 首页
  • 题库
  • 题解
  • 分享
  • 问答
  • 活动
  • 应用
  • 吐槽
  • 登录/注册

AcWing 90. 64位整数乘法

作者: 作者的头像   Rnin ,  2020-08-23 12:14:26 ,  阅读 63


1



#include <iostream>

#define Ull unsigned long long

using namespace std;

Ull quickMul( Ull a, Ull b, Ull p )
{
    Ull res=0, base=b;
    while ( a )
    {
        if ( a & 1 ) res = (res+base)%p;
        base = (base+base)%p;
        a >>= 1;
    }
    return res;

}

int main()
{
    Ull a, b, p, s;
    cin >> a >> b >> p;
    s = quickMul(a, b, p);
    cout << s << endl;
    return 0;

}

0 评论

你确定删除吗?

© 2018-2021 AcWing 版权所有  |  京ICP备17053197号-1
联系我们  |  常见问题
AcWing
请输入登录信息
更多登录方式: 微信图标 qq图标
请输入绑定的邮箱地址
请输入注册信息