2018 Multi-University Training Contest 6 Solution

时间:2023-03-08 15:40:26
2018 Multi-University Training Contest 6 Solution

A - oval-and-rectangle

题意:给出一个椭圆的a 和 b,在$[0, b]中随机选择c$ 使得四个顶点在椭圆上构成一个矩形,求矩形周长期望

思路:求出每种矩形的周长,除以b(积分)

2018 Multi-University Training Contest 6 Solution

 #include<bits/stdc++.h>

 using namespace std;

 const double PI = acos(-1.0);

 double a, b;

 void RUN()
{
int t;
scanf("%d", &t);
while (t--)
{
scanf("%lf %lf", &a, &b);
double ans = * b + a * PI;
printf("%.6f\n", ans - 5e-);
}
} int main()
{
#ifdef LOCAL_JUDGE
freopen("Text.txt", "r", stdin);
#endif // LOCAL_JUDGE RUN(); #ifdef LOCAL_JUDGE
fclose(stdin);
#endif // LOCAL_JUDGE
return ;
}

B - bookshelf

留坑。

C - Ringland

留坑。

D - Shoot Game

留坑。

E - black-and-white

留坑。

F - foam-transformation

留坑。

G - Variance-MST

留坑。

H - Rectangle Outline

留坑。

I - Werewolf

题意:狼人杀游戏,每个人都会指明另一个人的身份,村民一定不会说谎,狼人可能说谎,求确定的村民和狼人

思路:若果全都是狼人,那么逻辑一定成立,所以确定的村民数量为0.对于狼人可以通过反证法证明,若1认为2是村民,2认为3为村民,3认为4为村民,4认为2为狼人,反证法得出12位狼人,以此类推,DFS一下即可

 #include<bits/stdc++.h>

 using namespace std;

 const int maxn = (int)1e5 + ;

 int n;
int ans1,ans2;
int fa[maxn];
char str[];
vector<pair<int, int> >wolf;
vector<int>human[maxn]; void Init(int n)
{
ans1 = ans2 = ;
for (int i = ; i <= n; ++i) fa[i] = i, human[i].clear();
wolf.clear();
} int find(int x)
{
return x == fa[x] ? fa[x] : fa[x] = find(fa[x]);
} void mix(int x, int y)
{
x = find(x), y = find(y);
if (x != y)
{
fa[x] = y;
}
} bool same(int x, int y)
{
return find(x) == find(y);
} void DFS(int u)
{
for (auto it : human[u])
{
++ans2;
DFS(it);
}
} void RUN()
{
int t;
scanf("%d", &t);
while (t--)
{
scanf("%d", &n);
Init(n);
for (int i = ; i <= n; ++i)
{
int u;
scanf("%d %s", &u, str);
if (str[] == 'v')
{
mix(i, u);
human[u].push_back(i);
}
else
{
wolf.push_back(make_pair(i, u));
}
}
for (auto it : wolf)
{
if (same(it.first, it.second))
{
++ans2;
DFS(it.second);
}
}
printf("%d %d\n", ans1, ans2);
}
} int main()
{
#ifdef LOCAL_JUDGE
freopen("Text.txt", "r", stdin);
#endif // LOCAL_JUDGE RUN(); #ifdef LOCAL_JUDGE
fclose(stdin);
#endif // LOCAL_JUDGE
return ;
}

J - Chopping hands

留坑。

K - sacul

留坑。

L - Pinball

题意:一个小球垂直下落在一个斜板上,求在斜板上弹几次

思路:分解小球运动(物理题)

 #include<bits/stdc++.h>

 using namespace std;

 const double g = 9.8;
double a, b, x, y; void RUN()
{
int t;
scanf("%d", &t);
while (t--)
{
scanf("%lf %lf %lf %lf", &a, &b, &x, &y);
x = -1.0 * x;
double Tan = b / a;
double arc = atan(Tan);
double vx = g * sin(arc);
double vy = g * cos(arc);
double h = (y - b / a * x) * cos(arc);
double dis = (y - b / a * x) * sin(arc) + x / cos(arc);
double t = sqrt( * dis / vx );
double per = sqrt( * h / vy);
int ans = ;
if (t > per)
{
ans++;
t -= per;
}
ans += t / (per * );
printf("%d\n", ans);
}
} int main()
{
#ifdef LOCAL_JUDGE
freopen("Text.txt", "r", stdin);
#endif // LOCAL_JUDGE RUN(); #ifdef LOCAL_JUDGE
fclose(stdin);
#endif // LOCAL_JUDGE
return ;
}