以1234为例,将大整数分解成这种形式:1234 = ( ( 1 ∗ 10 + 2 ) ∗ 10 + 3 ) ∗ 10 + 4
1234=((1*10+2)*10+3)*10+41234=((1∗10+2)∗10+3)∗10+4,即从高位到低位,分别对大数的每一位上的数取模再乘10,再加上下一位上的数重复上述操作。
string s;
cin >> s;
int ans = 0;
for (auto ch : s) ans = ((ll)ans * 10 % MOD + ch - '0') % MOD;