2019暑期集训第二讲 - 组合数学&概率&数学期望
A - 容斥原理(CodeForces - 451E)
二进制状态压缩暴力枚举哪几个花选的个数超过了总个数,卢卡斯定理求组合数,容斥原理求答案
可以先把每个花的数量当成无限个,这样就是一个多重集的组合数$ans=C_{n+m-1}^{n-1}$
所以要减去有一种花超过花的数量的情况,加上有两种花超过花的数量的情况,减去有三种花超过花的数量的情况...
最后$ans=C_{n+m-1}^{n-1}-\sum_{i=1}^{n}C_{n+m-a_{i}-2}^{n-1}+\sum_{i=1}^{n}C_{n+m-a_{i}-a_{j}-3}^{n-1}-...+(-1)^{n}C_{n+m-\sum a_{i} -(n+1)}^{n-1}$
- #include <iostream>
- using namespace std;
- typedef long long ll;
- const int N = ;
- const int MOD = ;
- ll n, s, f[N];
- ll qPow(ll a, ll k, ll p)
- {
- ll ans = ;
- while (k) {
- if (k & ) ans = (ans * a) % p;
- a = (a * a) % p, k /= ;
- }
- return ans;
- }
- ll C(ll a, ll b, ll p)
- {
- if (a < b) return ;
- if (b > a - b) b = a - b;
- ll up = , down = ;
- for (ll i = ; i < b; i++) {
- up = up * (a - i) % p;
- down = down * (i + ) % p;
- }
- return up * qPow(down, p - , p) % p;
- }
- ll Lucas(ll a, ll b, ll p) {
- if (b == ) return ;
- return C(a%p, b%p, p) * Lucas(a / p, b / p, p) % p;
- }
- ll solve()
- {
- ll res = ;
- for (int i = ; i < ( << n); i++) {
- ll t = s, sign = ;
- for (int j = ; j < n; j++) {
- if (i & ( << j)) t -= (f[j] + ), sign *= -;
- }
- if (t < ) continue;
- res = (res + sign * Lucas(t + n - , n - , MOD)) % MOD;
- }
- return (res + MOD) % MOD;
- }
- int main()
- {
- cin >> n >> s;
- for (int i = ; i < n; i++) cin >> f[i];
- cout << solve() << endl;
- return ;
- }
A - 容斥原理(CodeForces - 451E)
B - 危险的组合(Critical Mass,UVa580)
设答案为$f(n)$,分两种情况:
- 当加入第$n$个元素时组成三个放在一起的U,那么第$n - 1,n - 2$都为U,第$n - 3$为L,保证前$n-4$个元素不会出现三个U放在一起,所以此时有$2^{n-4} - f(n - 4)$种可能
- 当前$n - 1$个元素已经形成了三个放在一起的U,那么第$n$个是U还是L都能形成三个放在一起的U,所以此时有$2 * f(n - 1)$中可能
得出递推关系式$f(n)=2 * f(n - 1) + 2^{n-4} - f(n - 4)$
- #include <iostream>
- using namespace std;
- const int N = ;
- long long cnt[N];
- // 快速幂
- long long power(long long a, long long n)
- {
- long long ans = ;
- while (n > ) {
- if ( == n % ) ans *= a;
- a *= a; n /= ;
- }
- return ans;
- }
- int main()
- {
- long long n;
- while (cin >> n && != n) {
- cnt[] = ;
- for (int i = ; i <= n; i++) {
- // 递推公式
- cnt[i] = * cnt[i - ] + power(, i - ) - cnt[i - ];
- }
- cout << cnt[n] << endl;
- }
- return ;
- }
B - 危险的组合(Critical Mass,UVa580)
C - 杆子的排序(Pole Arrangement,UVa1638)
设有$n$个杆子,从左边看能看到$l$根,从右边看能$r$跟时的答案是$f(n,l,r)$,插入高度为n的杆子不好讨论,所以考虑插入高度为1的杆子时的有三种情况:
- 插到最左边,则从左边能看见,从右边看不见,这时有$f(n-1,l-1,r)$种可能
- 插到最右边,则从右边能看见,从左边看不见,这时有$f(n-1,l,r-1)$种可能
- 插到中间(有$n-2$个插入的位置),不管从右边还是左边都看不见,这时有$f(n-1,l,r)*(n-2)$
得出递推关系式$f(n,l,r)=f(n-1,l-1,r)+f(n-1,l,r-1)+f(n-1,l,r)*(n-2)$
- #include <iostream>
- using namespace std;
- const int N = ;
- long long cnt[N][N][N];
- long long n, l, r, t;
- void init()
- {
- cnt[][][] = ;
- for (long long i = ; i <= ; i++) {
- for (long long l = ; l <= i; l++) {
- for (long long r = ; r <= i; r++) {
- cnt[i][l][r] = cnt[i - ][l - ][r] + cnt[i - ][l][r - ] + (i - ) * cnt[i - ][l][r];
- }
- }
- }
- }
- int main()
- {
- init(); cin >> t;
- while (t--) {
- cin >> n >> l >> r;
- cout << cnt[n][l][r] << endl;
- }
- return ;
- }
C - 杆子的排序(Pole Arrangement,UVa1638)
D - 比赛名次(Race,UVa12034)
设答案为$f(n)$,假设第一名有$i$个人,则有$C(n,i)$种可能,接下来的有$f(n-i)$种可能性,所以答案$f(n)=\sum_{i=1}^{i=n} C(n,i)*f(n-i)$,打个表即可
- #include <iostream>
- using namespace std;
- const int N = ;
- const int P = ;
- long long C[N][N];
- long long F[N];
- long long t, n, icas;
- void init()
- {
- for (int i = ; i < N; i++) C[i][] = i, C[i][] = ;
- for (int i = ; i < N; i++) {
- for (int j = ; j <= i; j++) {
- C[i][j] = (C[i - ][j] + C[i - ][j - ]) % P;
- }
- }
- F[] = F[] = ;
- for (int n = ; n < N; n++) {
- for (int i = n; i >= ; i--) {
- F[n] = (F[n] + (F[n - i] * C[n][i]) % P) % P;
- }
- }
- }
- int main()
- {
- init(); cin >> t;
- while (t--) {
- cin >> n;
- cout << "Case " << ++icas << ": " << F[n] << endl;
- }
- return ;
- }
D - 比赛名次(Race,UVa12034)
E - 麻球繁衍(Tribbles,UVa11021)
由于每只的麻球的后代独立存活,所以只用求出一个麻球$m$天后全部死亡的概率$f(m)$,最后的答案就是$f(m)^{k}$
第一天出生的麻球会在$m-1$后全部死亡,所以$f(m)=P_{0} + P_{1}*f(m-1)+P_{2}*f(m-1)^{2} + ...+P_{n-1}*f(m-1)^{n-1}$
第二天出生的麻球会在$m-2$后全部死亡,所以$f(m-1)=P_{0} + P_{1}*f(m-2)+P_{2}*f(m-2)^{2} + ...+P_{n-1}*f(m-2)^{n-1}$
到第$i$天全部死亡的概率$f(i)=P_{0} + P_{1}*f(i-1)+P_{2}*f(i-1)^{2} + ...+P_{n-1}*f(i-1)^{n-1}$
- #include <iostream>
- #include <iomanip>
- #include <cstring>
- #include <algorithm>
- using namespace std;
- const int N = ;
- double p[N], f[N];
- int t, n, k, m, icas;
- int main()
- {
- cin >> t;
- while (t--) {
- cin >> n >> k >> m;
- memset(f, , sizeof(f));
- for (int i = ; i < n; i++) cin >> p[i];
- for (int i = ; i <= m; i++) {
- double tp = ;
- for (int j = ; j < n; j++) {
- f[i] += (p[j] * tp), tp *= f[i - ];
- }
- }
- double res = ;
- for (int i = ; i < k; i++) res *= f[m];
- cout << "Case #" << ++icas << ": " << fixed << setprecision() << res << endl;
- }
- return ;
- }
E - 麻球繁衍(Tribbles,UVa11021)
F - 玩纸牌(Expect the Expected,UVa11427)
设$p(i,j)$表示玩$i$局赢$j$局的概率,所以当$j>0$时,$p(i,j)=p(i-1,j-1)*\frac{a}{b}+p(i-1,j)*(1-\frac{a}{b})$,当$j=0$时,第$i$局输,所以$p(i,j)=p(i-1,j)*(1-\frac{a}{b})$
设每天晚上垂头丧气去睡觉的概率为$q$,所以$q=\sum_{i=0}^{i*b\leqslant a*n}p(n,i)$
设数学期望为$E$天,第一天晚上有两种情况发生:
- 第一天晚上垂头丧气去睡觉,概率为$q$,所以能玩纸牌天数的数学期望为1
- 第一天晚上高高兴兴去睡觉,概率为$1 - q$,因为第一天和第二天独立,所以能玩纸牌天数的数学期望为$E + 1$
根据全期望公式有$E = q * 1 + (1 - q) * (E + 1)$,解得$E = 1 / q$
- #include <iostream>
- #include <cstring>
- using namespace std;
- const int N = ;
- char ch;
- int t, n, a, b, icas;
- double p[N][N];
- double cal()
- {
- memset(p, , sizeof(p));
- p[][] = ;
- for (int i = ; i <= n; i++) {
- for (int j = ; j <= i && j * b <= a * i; j++) {
- if (j > ) p[i][j] = p[i - ][j - ] * a / b + p[i - ][j] * ( - 1.0 * a / b);
- else p[i][j] = p[i - ][j] * ( - 1.0 * a / b);
- }
- }
- double q = ;
- for (int i = ; i <= n && i * b <= a * n; i++) q += p[n][i];
- return int(1.0 / q);
- }
- int main()
- {
- cin >> t;
- while (t--) {
- cin >> a >> ch >> b >> n;
- cout << "Case #" << ++icas << ": " << cal() << endl;
- }
- return ;
- }
F - 玩纸牌(Expect the Expected,UVa11427)
G - 得到1(Race to 1,UVa11762)
设$f(x)$为当前数为$x$时接下来需要操作的次数,不超过$x$的素数个数为$p(x)$,不超过$x$而且能被$x$整除的素数个数为$g(x)$
每一次选取都要操作一次,所以由全概率公式有$f(x)=1+[1-\frac{g(x)}{p(x)}]*f(x)+\sum _{0=x\%y}\frac{f(\frac{x}{y})}{p}$
化简后得$f(x)=\frac{p(x)+\sum _{0=x\%y}\frac{f(\frac{x}{y})}{p}}{g(x)}$
- #include <iostream>
- #include <cstring>
- #include <iomanip>
- using namespace std;
- const int N = ;
- int isprime[N];
- int prime[N];
- int vis[N];
- double f[N];
- int tot, t, n, icas;
- void get_prime(int n)
- {
- memset(isprime, , sizeof(isprime));
- for (int i = ; i <= n; i++) {
- if (!isprime[i]) prime[++tot] = i;
- for (int j = ; j <= tot; j++) {
- if (i * prime[j] > n) break;
- isprime[i * prime[j]] = ;
- if ( == i % prime[j]) break;
- }
- }
- }
- double dp(int x)
- {
- if ( == x) return ;
- if (vis[x]) return f[x];
- vis[x] = ; int p = , g = ; double ans = ;
- for (int i = ; i <= tot && prime[i] <= x; i++) {
- p += ;
- if ( == x % prime[i]) { g += ; ans += dp(x / prime[i]); }
- }
- ans = (ans + p) / g;
- return f[x] = ans;
- }
- int main()
- {
- get_prime(N); cin >> t; f[] = ;
- while (t--) {
- cin >> n;
- cout << "Case " << ++icas << ": ";
- cout << fixed << setprecision() << dp(n) << endl;
- }
- return ;
- }
G - 得到1(Race to 1,UVa11762)
H - 决斗(Headshot,UVa1636)
设字符串的长度为$n$,子串中00的个数为$a$,0的个数为$b$,分别求直接再抠一枪和随机转一下的条件概率
- 直接再抠一枪,因为第一个是0,所以在第一个是0的条件下再抠一枪还是0的概率是$\frac{a}{b}$
- 随机转一下还是0的概率即是字串中0的个数,即$\frac{b}{n}$
两者同时乘$b*n$后比较两者大小即可
- #include <iostream>
- #include <string>
- using namespace std;
- string s;
- int main()
- {
- while (cin >> s) {
- int a = , b = , n = (int)s.size();
- for (int i = ; i < n; i++) {
- if ('' == s[i]) a += ;
- if ('' == s[i] && '' == s[(i + ) % n]) b += ;
- }
- if (b * n > a * a) cout << "SHOOT" << endl;
- else if (b * n < a * a) cout << "ROTATE" << endl;
- else cout << "EQUAL" << endl;
- }
- return ;
- }
H - 决斗(Headshot,UVa1636)
I - 奶牛和轿车(Cows and Cars,UVa10491)
和三门问题一样
- 第一次选到牛的概率为$\frac{a}{a+b}$,打开$c$扇门后换门选到车的概率为$\frac{b}{a+b-c-1}$
- 第一次选到车的概率为$\frac{b}{a+b}$,打开$c$扇门后换门就不能选第一次选的门了,所以这是车的数量为$b-1$,所以选到车的概率为$\frac{b-1}{a+b-c-1}$
所以由全概率公式有赢得车的概率为$\frac{a*b+b*(b-1)}{(a+b)*(a+b-c-1)}$
- #include <iostream>
- #include <iomanip>
- using namespace std;
- int main()
- {
- double a, b, c;
- while (cin >> a >> b >> c) {
- double res = (b * (a + b - )) / ((a + b) * (a + b - c - ));
- cout << fixed << setprecision() << res << endl;
- }
- return ;
- }
I - 奶牛和轿车(Cows and Cars,UVa10491)
J - 条件概率(Probability|Given,UVa11181)
条件概率的公式为$p(E_{i}|E)=\frac{p(E_{i} E)}{p(E)}$
所以要通过深搜算出$n$个人中$r$买物品的概率$p(E)$,算出第$i$个人买物品的同时有$r$个人买物品的概率$p(E_{i} E)$
- #include <iostream>
- #include <iomanip>
- #include <cstring>
- using namespace std;
- const int N = ;
- int n, r, icas;
- double p[N], sum[N], tot;
- void dfs_tot(int cur, int num, double q)
- {
- if (cur == n) {
- if (num == r) tot += q;
- return;
- }
- else {
- dfs_tot(cur + , num + , q * p[cur]);
- dfs_tot(cur + , num, q * ( - p[cur]));
- }
- }
- void dfs_sum(int cur, int num, double q, int idx)
- {
- if (cur == n) {
- if (num == r - ) sum[idx] += q;
- return;
- }
- else {
- if (cur != idx) {
- dfs_sum(cur + , num + , q * p[cur], idx);
- dfs_sum(cur + , num, q * ( - p[cur]), idx);
- }
- else dfs_sum(cur + , num, q, idx);
- }
- }
- int main()
- {
- while (cin >> n >> r) {
- memset(sum, , sizeof(sum)), tot = ;
- if ( == n && == r) break;
- for (int i = ; i < n; i++) cin >> p[i];
- dfs_tot(, , );
- for (int i = ; i < n; i++) {
- dfs_sum(, , , i); sum[i] *= p[i];
- }
- cout << "Case " << ++icas << ":" << endl;
- for (int i = ; i < n; i++) {
- cout << fixed << setprecision() << sum[i] / tot << endl;
- }
- }
- return ;
- }
J - 条件概率(Probability|Given,UVa11181)
K - 纸牌游戏(Double Patience,UVa1637)
用九元组vector<int> cnt(9,4)来存储状态,用map< vector<int> cnt, double > mp来映射一个状态的成功的概率
- #include <iostream>
- #include <algorithm>
- #include <cstdio>
- #include <vector>
- #include <map>
- using namespace std;
- const int N = ;
- const int M = ;
- map< vector<int>, double > mp;
- char ch[N][M][];
- // 读取
- bool read_card()
- {
- for (int i = ; i < N; i++) {
- for (int j = ; j < M; j++) {
- if (scanf("%s", ch[i][j]) != ) return false;
- }
- }
- return true;
- }
- // cnt表示牌堆状态,c表示现在卡牌的数量
- double dp(vector<int> &cnt, int c)
- {
- if ( == c) return ;
- if ( != mp.count(cnt)) return mp[cnt];
- int tot = ; double sum = ;
- for (int i = ; i < N; i++) { // 选中的第一个牌堆
- for (int j = i + ; j < N; j++) { // 选中的第二个牌堆
- if (cnt[i] && cnt[j] && ch[i][cnt[i] - ][] == ch[j][cnt[j] - ][]) {
- // 两个牌堆都有牌而且顶部的卡牌满足要求
- cnt[i] -= , cnt[j] -= ;
- tot += , sum += dp(cnt, c - );
- cnt[i] += , cnt[j] += ;
- }
- }
- }
- if (!tot) return mp[cnt] = ;
- else return mp[cnt] = sum / tot;
- }
- int main()
- {
- while (read_card()) {
- vector<int> cnt(, ); // 初始化状态,9个牌堆,一个牌堆4张牌
- mp.clear();
- printf("%.6lf\n", dp(cnt, ));
- }
- return ;
- }
K - 纸牌游戏(Double Patience,UVa1637)
L - 过河(Crossing Rivers,UVa12230)
由于船在每个位置概率是相等的,所以过每条河的时间为$\frac{L}{v}$到$\frac{3* L}{v}$均匀分布,因此过河时间为$\frac{2* L}{v}$,再加上$D-sum(L)$
- #include <iostream>
- #include <iomanip>
- using namespace std;
- const int N = ;
- double p[N], l[N], v[N];
- double n, d, sum_l, res;
- int icas;
- int main()
- {
- while (cin >> n >> d) {
- if ( == n && == d) break;
- sum_l = , res = ;
- for (int i = ; i < n; i++) {
- cin >> p[i] >> l[i] >> v[i];
- sum_l += l[i], res += * l[i] / v[i];
- }
- res += (d - sum_l);
- cout << "Case " << ++icas << ": ";
- cout << fixed << setprecision() << res << endl << endl;
- }
- return ;
- }
L - 过河(Crossing Rivers,UVa12230)
M - 糖果(Candy,UVa1639)
假设最后一次打开第一个盒子,此时第二个盒子有$i$颗糖,则在这之前一共打开过$2*n-i$次盒子,其中有$n$次打开第一个盒子,最后一次要打开第一个盒子,所以概率为$C_{2*n-i}^{n}*p^{n+1}*(1-p)^{n-i}$
取对数有$v1(i)=In(C_{2*n-i}^{n})+(n+1)*In(p)+(n-i)*In(1-p)$,化简的$In(C_{2*n-i}^{n})=In\frac{(2*n-i)!}{n!*(n-i)!}=\sum _{k=1}^{2*n-i}In(k)-\sum _{k=1}^{n}In(k)$
所以$v1(i)=\sum _{k=1}^{2*n-i}In(k)-\sum _{k=1}^{n}In(k)+(n+1)*In(p)+(n-i)*In(1-p)$
同理$v2(i)=\sum _{k=1}^{2*n-i}In(k)-\sum _{k=1}^{n}In(k)+(n+1)*In(1-p)+(n-i)*In(p)$
- #include <iostream>
- #include <cmath>
- #include <iomanip>
- using namespace std;
- const int N = ;
- long double logc[ * N];
- long double p, res;
- int n, icas;
- void init()
- {
- for (int i = ; i < * N; i++) logc[i] = logc[i - ] + log(i);
- }
- int main()
- {
- init();
- while (cin >> n >> p) {
- res = ;
- for (int i = ; i <= n; i++) {
- long double c = logc[ * n - i] - logc[n] - logc[n - i];
- long double v1 = c + (n + ) * log(p) + (n - i) * log( - p);
- long double v2 = c + (n + ) * log( - p) + (n - i) * log(p);
- res += (i * (exp(v1) + exp(v2)));
- }
- cout << "Case " << ++icas << ": ";
- cout << fixed << setprecision() << res << endl;
- }
- return ;
- }
M - 糖果(Candy,UVa1639)
N - 优惠券(Coupons,UVa10288)
当已经拿到$k$张后,拿第$k+1$张时,拿到的概率为$Q=\frac{n-k}{n}$
设拿到第$k+1$的期望为$E$,分两种情况:
- 第一次就拿到第$k+1$张,概率为$Q$,期望是1
- 第一次没有拿到,因为每次拿都是独立的,所以概率为$1-Q$,期望是$E+1$
由全期望公式得$Q+(1-Q)*(E+1)=E$,解得$E=\frac{1}{Q}=\frac{n}{n-k}$
所以答案为$\sum _{k=0}^{n-1}\frac{n}{n-k}$
- #include <iostream>
- #include <algorithm>
- using namespace std;
- typedef long long ll;
- ll n, n_up, n_down, pre;
- ll num_pre, num_n_up, num_n_down;
- ll gcd(ll a, ll b)
- {
- return == b ? a : gcd(b, a % b);
- }
- void cal(ll up, ll down)
- {
- ll tp_up = n_up * down + n_down * up;
- ll tp_down = n_down * down;
- pre += (tp_up / tp_down), tp_up %= tp_down;
- ll gcd_num = gcd(tp_up, tp_down);
- if ( != gcd_num) n_up = tp_up / gcd_num, n_down = tp_down / gcd_num;
- else n_up = tp_up, n_down = tp_down;
- }
- int main()
- {
- while (cin >> n) {
- n_up = n_down = n, pre = ;
- num_pre = num_n_up = num_n_down = ;
- for (ll i = n - ; i >= ; i--) cal(n, i);
- ll tp_n_up = n_up, tp_n_down = n_down, tp_pre = pre;
- if ( == n_up) cout << pre << endl;
- else if ( == pre) cout << << endl;
- else {
- while (tp_n_up) num_n_up += , tp_n_up /= ;
- while (tp_n_down) num_n_down += , tp_n_down /= ;
- while (tp_pre) num_pre += , tp_pre /= ;
- ll num_ = max(num_n_up, num_n_down);
- for (int i = ; i < num_pre + ; i++) cout << " ";
- cout << n_up << endl;
- cout << pre << " ";
- for (int i = ; i < num_; i++) {
- if (i == num_ - ) cout << "-" << endl;
- else cout << "-";
- }
- for (int i = ; i < num_pre + ; i++) cout << " ";
- cout << n_down << endl;
- }
- }
- return ;
- }
N - 优惠券(Coupons,UVa10288)
2019暑期集训第二讲 - 组合数学&概率&数学期望的更多相关文章
- best coder #35-01<组合数学 || 概率数学>
问题描述 一个盒子里有n个黑球和m个白球.现在DZY每次随机从盒子里取走一个球,取了n+m次后,刚好取完.DZY用这种奇怪的方法生成了一个随机的01串S[1⋯(n+m)].如果DZY第i次取出的球是黑 ...
- 算法讲堂二:组合数学 & 概率期望DP
组合数学 1. 排列组合 1. 加法原理 完成一列事的方法有 n 类,其中第 i 类方法包括\(a_i\)种不同的方法,且这些方法互不重合,则完成这件事共有 \(a_1 + a_2 + \cdots ...
- $2019$ 暑期刷题记录1:(算法竞赛DP练习)
$ 2019 $ 暑期刷题记录: $ POJ~1952~~BUY~LOW, BUY~LOWER: $ (复杂度优化) 题目大意:统计可重序列中最长上升子序列的方案数. 题目很直接的说明了所求为 $ L ...
- 暑期集训日志(Day6~Day17)
章·十七:2019-07-28:为谁辛苦为谁甜 ·昨日小结 颓爆了QAQ,昨天又垫底了. 最简单一道题弃疗的我直接被甩倒了总榜垫底…… 我……不想说啥…… 我是渣比. 我不能颓废了. 醒来啊麦克白! ...
- 2014年CCNU-ACM暑期集训总结
2014年CCNU-ACM暑期集训总结 那个本期待已久的暑期集训居然就这种.溜走了.让自己有点措手不及.很多其它的是对自己的疑问.自己是否能在ACM这个领域有所成就.带着这个疑问,先对这个暑假做个总结 ...
- 【整理】简单的数学期望和概率DP
数学期望 P=Σ每一种状态*对应的概率. 因为不可能枚举完所有的状态,有时也不可能枚举完,比如抛硬币,有可能一直是正面,etc.在没有接触数学期望时看到数学期望的题可能会觉得很阔怕(因为我高中就是这么 ...
- 2014 SCAU_ACM 暑期集训
暑期集训,希望能在这段时间获得对得起自己的提升吧 时间:7.11~8.30 集训各专题内容: 1.贪心,递推,基础DP(背包,区间DP,状态压缩DP(去年出了不少于2道铜牌题,看着办)) 2.搜索(B ...
- SDU暑期集训排位(5)
SDU暑期集训排位(5) A. You're in the Army Now 题意 类似选志愿.每个人有 mark,有优先级从高到低的志愿. 做法 定睛一看,鲨鼻题.然后 WA. 为什么会 WA 呢? ...
- UVa 11427 Expect the Expected (数学期望 + 概率DP)
题意:某个人每天晚上都玩游戏,如果第一次就䊨了就高兴的去睡觉了,否则就继续直到赢的局数的比例严格大于 p,并且他每局获胜的概率也是 p,但是你最玩 n 局,但是如果比例一直超不过 p 的话,你将不高兴 ...
随机推荐
- pyqt中定时器的使用
1.定义一个定时器函数 # 定时器 from PyQt5.QtCore import QTimer def timer_start(): timer = QTimer() # fun1是监听的函数,如 ...
- office自签名证书
在 Office安装目录,找到 SELFCERT 文件,双击打开填写名称,生成
- AttributeError: This QueryDict instance is immutable
当写添加注册后端时,运行当运行时,会出现: "AttributeError: This QueryDict instance is immutable": 因为默认的 QueryD ...
- easyExcel+poi导出Excel出现乱码
这种问题肯定是浏览器编码问题,修改官方给的util就好了
- word中如何删除一张空白表格
百度知道:https://baijiahao.baidu.com/s?id=1631677477148377412&wfr=spider&for=pc 当word中出现如下一张空白表格 ...
- C:数组基础
数组 在程序设计中,为了方便处理数据把具有相同类型的若干变量按有序形式组织起来--称为数组. 数组就是在内存中连续的相同类型的变量空间.同一个数组所有的成员都是相同的数据类型,同时所有的成员在内存中的 ...
- spring中@Component注解
1.@controller 控制器(注入服务) 2.@service 业务(注入dao) 3.@repository dao(实现dao访问) 4.@component (把普通pojo实例化到spr ...
- 【Struts 动态表单】DynaActionForm
RegisterAction package k.action; import org.apache.struts.action.ActionForm; import org.apache.strut ...
- 洛谷 P5018 对称二叉树(搜索)
嗯... 题目链接:https://www.luogu.org/problem/P5018 其实这道题直接搜索就可以搜满分: 首先递归把每个点作为根节点的儿子的数量初始化出来,然后看这个节点作为根节点 ...
- Centos610 Oracle 监听文件配置参考
lister.ora配置参考 # listener.ora Network Configuration File: /home/oracle/app/oracle/product//dbhome_1/ ...