2018 Multi-University Training Contest 6 Solution

A - oval-and-rectangle

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

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

 1 #include<bits/stdc++.h>
 2 
 3 using namespace std;
 4 
 5 const double PI = acos(-1.0);
 6 
 7 double a, b;
 8 
 9 void RUN()
10 {
11     int t;
12     scanf("%d", &t);
13     while (t--)
14     {
15         scanf("%lf %lf", &a, &b);
16         double ans = 2 * b + a * PI;
17         printf("%.6f\n", ans - 5e-7);
18     }
19 }
20 
21 int main()
22 {
23 #ifdef LOCAL_JUDGE
24     freopen("Text.txt", "r", stdin);
25 #endif // LOCAL_JUDGE
26 
27     RUN();
28 
29 #ifdef LOCAL_JUDGE
30     fclose(stdin);
31 #endif // LOCAL_JUDGE
32     return 0;
33 }
View Code

 

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一下即可

 1 #include<bits/stdc++.h>
 2 
 3 using namespace std;
 4 
 5 const int maxn = (int)1e5 + 10;
 6 
 7 int n;
 8 int ans1,ans2;
 9 int fa[maxn];
10 char str[110];
11 vector<pair<int, int> >wolf;
12 vector<int>human[maxn];
13 
14 void Init(int n)
15 {
16     ans1 = ans2 = 0;
17     for (int i = 0; i <= n; ++i) fa[i] = i, human[i].clear();
18     wolf.clear();
19 }
20 
21 int find(int x)
22 {
23     return x == fa[x] ? fa[x] : fa[x] = find(fa[x]);
24 }
25 
26 void mix(int x, int y)
27 {
28     x = find(x), y = find(y);
29     if (x != y)
30     {
31         fa[x] = y;
32     }
33 }
34 
35 bool same(int x, int y)
36 {
37     return find(x) == find(y);
38 }
39 
40 void DFS(int u)
41 {
42     for (auto it : human[u])
43     {
44         ++ans2;
45         DFS(it);
46     }
47 }
48 
49 void RUN()
50 {
51     int t;
52     scanf("%d", &t);
53     while (t--)
54     {
55         scanf("%d", &n);
56         Init(n);
57         for (int i = 1; i <= n; ++i)
58         {
59             int u;
60             scanf("%d %s", &u, str);
61             if (str[0] == 'v')
62             {
63                 mix(i, u);
64                 human[u].push_back(i);
65             }
66             else
67             {
68                 wolf.push_back(make_pair(i, u));
69             }
70         }
71         for (auto it : wolf)
72         {
73             if (same(it.first, it.second))
74             {
75                 ++ans2;
76                 DFS(it.second);
77             }
78         }
79         printf("%d %d\n", ans1, ans2);
80     }
81 }
82 
83 int main()
84 {
85 #ifdef LOCAL_JUDGE
86     freopen("Text.txt", "r", stdin);
87 #endif // LOCAL_JUDGE
88 
89     RUN();
90 
91 #ifdef LOCAL_JUDGE
92     fclose(stdin);
93 #endif // LOCAL_JUDGE
94     return 0;
95 }
View Code

 

J - Chopping hands

留坑。

 

K - sacul

留坑。

 

L - Pinball

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

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

 1 #include<bits/stdc++.h>
 2 
 3 using namespace std;
 4 
 5 const double g = 9.8;
 6 double a, b, x, y;
 7 
 8 void RUN()
 9 {
10     int t;
11     scanf("%d", &t);
12     while (t--)
13     {
14         scanf("%lf %lf %lf %lf", &a, &b, &x, &y);
15         x = -1.0 * x;
16         double Tan = b / a;
17         double arc = atan(Tan);
18         double vx = g * sin(arc);
19         double vy = g * cos(arc);
20         double h = (y - b / a * x) * cos(arc);
21         double dis = (y - b / a * x) * sin(arc) + x / cos(arc);
22         double t = sqrt(2 * dis / vx );
23         double per = sqrt(2 * h / vy);
24         int ans = 0;
25         if (t > per)
26         {
27             ans++;
28             t -= per;
29         }
30         ans += t / (per * 2);
31         printf("%d\n", ans);
32     }
33 }
34 
35 int main()
36 {
37 #ifdef LOCAL_JUDGE
38     freopen("Text.txt", "r", stdin);
39 #endif // LOCAL_JUDGE
40 
41     RUN();
42 
43 #ifdef LOCAL_JUDGE
44     fclose(stdin);
45 #endif // LOCAL_JUDGE
46     return 0;
47 }
View Code

 

posted @ 2018-10-07 16:52  Dup4  阅读(203)  评论(0编辑  收藏  举报