mirror of
https://github.com/Hizenberg469/Algorithms-snippets.git
synced 2026-04-19 14:42:23 +03:00
String%n for string with more than 20 digit
This commit is contained in:
11
Number Theory/string_mod_int.cpp
Normal file
11
Number Theory/string_mod_int.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
int operator%(string& a , int b){
|
||||
|
||||
int sz = (int)a.size();
|
||||
int val = 0;
|
||||
for(int idx = 0 ; idx < sz ; idx++ ){
|
||||
val = 10*val + (a[idx]-'0');
|
||||
val %= b;
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
Reference in New Issue
Block a user