题目位置:https://www.acwing.com/problem/content/92/
#include<iostream>
using namespace std;
typedef long long LL;
int main()
{
LL a,b,p;
cin>>a>>b>>p;
LL ans=0;
while(b)
{
if(b&1)ans=(ans+a)%p;
a=a*2%p;
b>>=1;
}
cout<<ans<<endl;
return 0;
}