MnZn 刚学 OI,本地能过提交 RE

P5684 [CSP-J2019 江西] 非回文串

Orz
by ListenSnow @ 2022-09-08 20:53:38


Orz
by Democlight @ 2022-09-08 20:59:13


```cpp # include <bits/stdc++.h> # define int long long # define wheneveright signed main using namespace std; const int maxn = 5005; const int mod = 1000000007; int KSM (int x, int y = mod - 2) { int ret = 1; while (y) { if (y & 1) ret = ret * x % mod; x = x * x % mod; y >>= 1; } return ret % mod; } int n, res, odd; int fac[maxn], inv[maxn]; char s[maxn]; int cnt[27]; wheneveright () { scanf ("%lld%s", & n, s + 1); fac[0] = inv[0] = 1; for (int i = 1; i <= n; i++) inv[i] = KSM (fac[i] = fac[i - 1] * i % mod); for (char i : s) cnt[i - 'a']++; for (int i = 0; i < 26; i++) odd += cnt[i] & 1; if (odd > 1) { printf ("%lld\n", fac[n] % mod); return 0; } odd = 1; for (int i = 0; i < 26; i++) if (cnt[i] & 1) odd = cnt[i]; res = fac[n / 2] * odd % mod; for (int i = 0; i < 26; i++) res = res * fac[cnt[i]] % mod * inv[cnt[i] / 2] % mod; res = fac[n] - res; printf ("%lld\n", (res % mod + mod) % mod); return 0; } ```
by Micnation_AFO @ 2022-09-08 21:03:13


@[wheneveright](/user/189351) 不过还是 WA 70pts,剩下的我不会了/kk
by Micnation_AFO @ 2022-09-08 21:05:57


@[Leap_hash_jperm](/user/574944) 谢谢,刚刚也发现这个问题了, Linux 环境不同的问题
by wheneveright @ 2022-09-08 21:11:01


|