IcePrincess_1968 探测到IcePrince_1968 近期的 m 个与 IcePrincess_1968 相关的梦境转折点, 第 i 个转折点 ti 表示他的第 i 个梦境转折点会在 ti 时刻出现。 因为 IcePrince_1968 和 IcePrincess_1968 很有缘,IcePrince_1968 经常梦到 IcePrincess_1968, 所以 m 可能会很大。
intmain() { n = read(); m = read(); for(RG int i = 1; i <= n; i++) d[i] = (node) {read(), read()}; for(RG int i = 1; i <= m; i++) s.insert(t[i] = read());
std::sort(d + 1, d + n + 1, cmp); int ans = 0; std::multiset<int>::iterator it; for(RG int i = 1; i <= m; i++) { it = s.lower_bound(d[i].l); if(it == s.end() || *it > d[i].r) continue; ++ans; s.erase(it); } printf("%d\n", ans); return0; }
inlineintread() { int data = 0, w = 1; char ch = getchar(); while(ch != '-' && (ch < '0' || ch > '9')) ch = getchar(); if(ch == '-') w = -1, ch = getchar(); while(ch >= '0' && ch <= '9') data = data * 10 + (ch ^ 48), ch = getchar(); return data*w; }
constintmaxn(210); int n, p, inv[maxn]; inlineintInv(int x) { staticint ans, y; ans = 1; y = p - 2; x %= p; while(y) { if(y & 1) ans = 1ll * ans * x % p; x = 1ll * x * x % p; y >>= 1; } return ans; }
int dp[maxn][maxn], f[maxn][maxn], g[maxn][maxn], ans[maxn];
inlineintF(int i, int j); inlineintG(int i, int j) { if(j < 0) return0; if(i == 0) return1; if(~g[i][j]) return g[i][j]; g[i][j] = 0; for(RG int k = 1; k <= i; k++) g[i][j] = (g[i][j] + (1ll * (1ll * F(k, j) * G(i - k, j) % p) * dp[i][k]) % p) % p; return g[i][j]; }
inlineintF(int i, int j) { if(~f[i][j]) return f[i][j]; return f[i][j] = G(i - 1, j - 1); }
intmain() { n = read(); p = read(); inv[1] = 1; for(RG int i = 2; i <= n; i++) inv[i] = Inv(i); if(n == 0) returnputs("0") & 0; dp[1][1] = 1; for(RG int i = 2; i <= n; i++) for(RG int j = 1; j <= i; j++) dp[i][j] = ((1ll * (1ll * dp[i - 1][j - 1] * (j - 1) % p) * inv[i] % p) + (1ll * (1ll * dp[i - 1][j] * (i - j) % p) * inv[i] % p)) % p; clear(f, -1); clear(g, -1); for(RG int i = 2; i <= n; i++) ans[i] = F(n, i); ans[1] = 0; int ANS = 0; for(RG int i = 2; i <= n; i++) ANS = (ANS + (1ll * ((ans[i] - ans[i - 1]) % p) * i) % p) % p; printf("%d\n", (ANS - 1 + p) % p); return0; }