描述
求 a 乘 b 对 p 取模的值,其中 1≤a,b,p≤10^18。
输入格式
第一行a,第二行b,第三行p。
输出格式
一个整数,表示a*b mod p的值。
样例输入
2
3
9
样例输出
6
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5+5;
const int INF = 0x3f3f3f3f;
int n, ans;
#define ll long long
ll a,b,p;
ll qmod(ll a,ll b,ll p)
{ll res=0; //while(b){if(b&1)res=(res%p+a%p)%p; //a=(a+a)%p; //b>>=1;}return res%p;
}
int main()
{while(~scanf("%lld%lld%lld",&a,&b,&p)){printf("%lld\n",qmod(a,b,p));}return 0;
}