int mod(string num, int a)
{
// Initialize result
int res = 0;
// One by one process all digits of 'num'
for (int i = 0; i < num.length(); i++)
res = (res*10 + (int)num[i] - '0') %a;
return res;
}
祝大家解這題(和其他很多大數mod題)順利! ^_^