2018 Multi-University Training Contest 6 Solution
A - oval-and-rectangle
题意:给出一个椭圆的a 和 b,在$[0, b]中随机选择c$ 使得四个顶点在椭圆上构成一个矩形,求矩形周长期望
思路:求出每种矩形的周长,除以b(积分)
- #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 ;
- }
2018 Multi-University Training Contest 6 Solution的更多相关文章
- 2018 Multi-University Training Contest 1 Solution
A - Maximum Multiple 题意:给出一个n 找x, y, z 使得$n = x + y +z$ 并且 $n \equiv 0 \pmod x, n \equiv 0 \pmod y, ...
- 2018 Multi-University Training Contest 2 Solution
A - Absolute 留坑. B - Counting Permutations 留坑. C - Cover 留坑. D - Game puts("Yes") #include ...
- 2018 Multi-University Training Contest 3 Solution
A - Problem A. Ascending Rating 题意:给出n个数,给出区间长度m.对于每个区间,初始值的max为0,cnt为0.遇到一个a[i] > ans, 更新ans并且cn ...
- 2018 Multi-University Training Contest 4 Solution
A - Problem A. Integers Exhibition 留坑. B - Problem B. Harvest of Apples 题意:计算$\sum_{i = 0}^{i = m}C( ...
- 2018 Multi-University Training Contest 5 Solution
A - Always Online Unsolved. B - Beautiful Now Solved. 题意: 给出一个n, k 每次可以将n这个数字上的某两位交换,最多交换k次,求交换后的最大 ...
- 2018 Multi-University Training Contest 7 Solution
A - Age of Moyu 题意:给出一张图,从1走到n,如果相邻两次走的边的权值不同,花费+1, 否则花费相同,求最小花费 思路:用set记录有当前点的最小花费有多少种方案到达,然后最短路 #i ...
- 2018 Multi-University Training Contest 8 Solution
A - Character Encoding 题意:用m个$0-n-1$的数去构成k,求方案数 思路:当没有0-n-1这个条件是答案为C(k+m-1, m-1),减去有大于的关于n的情况,当有i个n时 ...
- 2018 Multi-University Training Contest 9 Solution
A - Rikka with Nash Equilibrium 题意:构造一个$n * m$的矩阵,使得$[1, n * m]$ 中每个数只出现一次,并且纳什均衡只出现一次. 思路:从大到小的放置,每 ...
- 2018 Multi-University Training Contest 10 Solution
A - Problem A.Alkane 留坑. B - Problem B. Beads 留坑. C - Problem C. Calculate 留坑. D - Problem D. Permut ...
随机推荐
- ionic调用数据接口(post、解决 payload 问题)
$http({method:'POST', url:apiUrl, headers:{'Content-Type': 'application/x-www-form-urlencoded; chars ...
- Linux mysqladmin 命令
mysqladmin命令可以用来设置或修改 MySQL 密码,常见用法如下: [root@localhost ~]$ mysqladmin -uroot password 'newPass' # 在无 ...
- Python 列表表达式与生成器表达式
列表表达式: (1) 语法1:[表达式 for 变量 in 列表],表示把得到的每一个变量值都放到 for 前面的表达式中计算 ,然后生成一个列表(2) 语法2:[表达式 for 变量 in 列表 i ...
- iOS设计模式之类族(class cluster)
类族模式在UIKit(user interface framework)使用的范围已经远远超过我们的想象,比如,UIButton,NSArray,NSString,NSNumber等, 例如NSNum ...
- c++11——std::function和bind绑定器
c++11中增加了std::function和std::bind,可更加方便的使用标准库,同时也可方便的进行延时求值. 可调用对象 c++中的可调用对象存在以下几类: (1)函数指针 (2)具有ope ...
- 高中生的IT之路-1.1自序
近几年来越来越多的人问我关于 高中生要不要读大学.大学选择专业.毕业后的择业问题,索性我不如把我对这几方面的理解写出来,如果有幸能帮助到更多的人,那也算是个人对社会做出了一点贡献. ...
- TextureMerger1.6.6 三:Bitmap Font的制作和使用
BitmapFont主要用于特殊字体在游戏中的使用. 比如我想使用方正剪纸字体,但是没加载方正剪纸.ttf字体时,egret是没法使用这种字体的. 或者美工制作了效果拔群的0123456789数字字体 ...
- 查询hadoop参数变量
[hadoop@master hadoop]$ hive -S -e 'set -v'|grep querylog|grep -E -v 'CLASSPATH|class'hive.querylog. ...
- 判断手机访问还是pc访问
function isMobile(){ // 如果有HTTP_X_WAP_PROFILE则一定是移动设备 if (isset ($_SERVER['HTTP_X_WAP_PROFILE'])) re ...
- JAVAWEB Filter使用
Filter学习 1Filter是什么:是过滤器简称 2Filter有什么作用:在filter中可以得到代表用户请求和响应的request.response对象,因此在编程中可以使用Decorator ...