在计算 res = res * (i + (LL)a * i - a) / i; 时,要把 /i 提到前面去,不然会爆 longlong。
res = res * (i + (LL)a * i - a) / i;
/i