inhuman_Arif

Big mod function

Jan 17th, 2021
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. ///Parameters are string which is a huge number, divisor which can be long but can fit in long long
  2. /// and loop initializer because string can start with negative sign
  3. int bigmod(string num,ll divisor,int i)
  4. {
  5.     ll res = 0;
  6.     for(int j=i;j<num.size();j++)
  7.         res = (res*10+(int)num[j]-'0')%divisor;
  8.     return res;
  9. }
Advertisement
Add Comment
Please, Sign In to add comment