对于计算空间, 不能只计算最大的地方的空间, 不要开多余的数组。
3266587292
struct FastMod
{
using ull=unsigned long long;
using L=__int128;
ull b,m;
void init(ull x){b=x;m=ull((L(1)<<64)/b);}
ull reduce(ull a)
{
if(b==1)return 0;
ull q=(ull)((L(m)*a)>>64),r=a-q*b;
return r>=b?r-b:r;
}
}F;