fork(1) download
  1. #include <iostream>
  2. unsigned long long mult(unsigned long long x,unsigned long long y,unsigned long long const z){
  3. if(y == 1)return x % z;
  4. else if( y== 0)return 0;
  5. else if(!(y & 1))return mult((x + x)%z,(y/2) % z,z);
  6. else return (x % z + mult(x % z,(y - 1) % z,z))%z;
  7.  
  8. }
  9. int main() {
  10. unsigned long long a,b,c;
  11. std::cin >> a >> b >> c;
  12. std::cout << mult(a,b,c);
  13. }
Success #stdin #stdout 0s 15232KB
stdin
100000000000000056 10000000000000567000 10000000007000000000000567
stdout
14225990052694228800