Contest Hunter P0102 64位整数乘法

目录:


题目:

传送门


分析:

一道快速乘的版题,把快速乘照搬就好了,在这里marker一下


代码 :

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#define LL long long
using namespace std;
inline LL read() {
    LL d=0,f=1;char s=getchar();
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
    while(s>='0'&&s<='9'){d=d*10+s-'0';s=getchar();}
    return d*f;
}
long mul(long long x,long long y,long long mod) {
    long long ret=x*y-(long long)((long double)x/mod*y+1.0e-8)*mod;
    return ret;
}
int main()
{
    long long x,y,m;
    x=read();y=read();m=read();
    printf("%lld",mul(x,y,m));
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_35786326/article/details/81667167