传送门 code
#include<bits/stdc++.h> using namespace std; unsigned long long a,b,c;// int main() { cin>>a>>b>>c; unsigned long long ans=0,now=a;// while(b>0) { if(b&1) { ans=(ans+now)%c; } now=now*2%c; b>>=1; } ans%=c; cout<<ans; return 0; }