這題鐵定要用string讀
附上大數mod函數(超好用,我用他拿AC,340KB)
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;
}
祝大家解題順利!!!