版本比较
[计数] [容斥] AT_agc058_d [AGC058D] Yet Another ABC String
正文
增加 2 行删除 2 行
40 行未改动41424344454546474849505151525354555 行未改动40 行未改动 jc[0] = jcinv[0] = 1; for(int i = 1; i < N; ++i) jc[i] = jc[i - 1] * i % mod; jcinv[N - 1] = qstp(jc[N - 1], mod - 2); for(int i = N - 2; i; --i) jcinv[i] = jcinv[i + 1] * (i + 1) % mod;
cin >> a >> b >> c; for(int i = 0, pw = 1, pw2 = 1; i <= min(a, min(b, c)); ++i){ int res, res2; res = jc[a + b + c - 3 * i] * jcinv[a - i] % mod * jcinv[b - i] % mod * jcinv[c - i] % mod; res2 = CC(i, a + b + c - 3 * i) * pw2 % mod; ADD(res2, CC(i - 1, a + b + c - 3 * i + 1) * pw2 % mod * inv2 % mod * 3ll % mod); ADD(res2, CC(i - 1, a + b + c - 3 * i + 1) * pw2 % mod * inv2 % mod * 3ll % mod); ADD(ans, res * res2 % mod * pw % mod) % mod; pw = (pw == 1 ? (mod - 1) : 1); pw2 = pw2 * 2ll % mod; }5 行未改动