B
F[i, j] |= F[i - 1, j - a[k]] 表示i桶油,j距离可行与否
对X的处理。不接受编译开关
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
//Love lemon_TsyD
//Miss lydrainbowcat
//By ITX351
const int MAXN = 1111, MAXL = 1111, T = 4;
int F[T + 3][MAXL]; int a[MAXN];
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
int Test;
scanf("%d", &Test);
while (Test--)
{
memset(F, 0, sizeof(F));
int L, X, N;
scanf("%d%d%d", &L, &X, &N);
for (int i = 1; i <= N; i++)
scanf("%d", a + i);
F[0][X] = true;
for (int i = 1; i <= T; i++)
for (int j = 0; j <= L; j++)
{
for (int k = 1; k <= N; k++)
if (j - a[k] >= 0)
F[i][j] |= F[i - 1][j - a[k]];
}
printf("%s\n", F[T][L] ? "Yes" : "No");
}
return 0;
}
C
结果只与L、H能整除多少个2的数量奇偶性有关
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
//Love lemon_TsyD
//Miss lydrainbowcat
//By ITX351
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
int Test;
scanf("%d", &Test);
while (Test--)
{
int L, H;
scanf("%d%d", &L, &H);
int ans = 0;
while (!(L & 1))
{
L >>= 1;
ans++;
}
while (!(H & 1))
{
H >>= 1;
ans++;
}
printf("%s\n", ans & 1 ? "Adidas loses" : "Adivon prevails");
}
return 0;
}
F
连续击中和不连续的混沌到一起考虑……每次击中后的期望积分都是上一次的积分加一,再乘以概率
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
//Love lemon_TsyD
//Miss lydrainbowcat
//By ITX351
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
int Test;
scanf("%d", &Test);
while (Test--)
{
int L; double P;
scanf("%d%lf", &L, &P);
double pre = .0, ans = .0;
for (int i = 1; i <= L; i++)
{
pre = (pre + 1.0) * P;
ans += pre;
}
printf("%.6lf\n", ans);
}
return 0;
}
H
一正一反的概率是p(1-p),期望除一。
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
//Love lemon_TsyD
//Miss lydrainbowcat
//By ITX351
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
int Test;
scanf("%d", &Test);
while (Test--)
{
double p;
scanf("%lf", &p);
double ans = 1.0 / (p * (1 - p));
printf("%.2lf\n", ans);
}
return 0;
}