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 ...
随机推荐
- ios 显示代码块(show the code snippet library)
在项目的实际开发中,我们会重复的书写很多的代码,我经常是需要用到某一个功能,就从以前的项目中复制粘贴过来,很是麻烦 下面就为大家提供两种不错的方法, 一.宏定义,这个大家应该很熟悉,在这里就不做多的介 ...
- Access数据操作-02
数据库连接 MDB文件 :Provider=Microsoft.Jet.OLEDB.4.0;Data Source=*.mdb ;Persist Security Info=False; AccDB文 ...
- Python 使用正则表达式匹配电话号码
一个电话号码,如果区号为3位,那么区号后面的数字为8位:如果区号为4位,那么区号后面的数字为7位 In [1]: import re In [2]: number = "020-232432 ...
- Qt监控Access数据库
配置文件setup.ini内容 [General] DBFilePath=C:/Users/WangGang/Desktop/Database1.accdb DBUserName= DBPasswor ...
- Django学习笔记 开发环境搭建
为什么使用django?1.支持快速开发:用python开发:数据库ORM系统,并不需要我们手动地构造SQL语句,而是用python的对象访问数据库,能够提升开发效率.2.大量内置应用:后台管理系统a ...
- linux IP 设置
修改ip地址即时生效:# ifconfig eth0 192.168.1.102 netmask 255.255.255.0启动生效:修改/etc/sysconfig/network-scripts/ ...
- MySQL - Show Processlist 整理
MySQL - Show Processlist 整理 原文来源:MySQL 5.5 Reference Manual 部分翻译取自:<MySQL_5.1中文参考手册> 转载请注明原文 ...
- 【ecshop】如何解决DEPRECATED: PREG_REPLACE()报错
部署的ecshop 在高版本的PHP环境里边 ,访问 单个店铺时候会报错, 访问文件路径: http://www.test.com/supplier.php?suppId=5 类似这样的报错: D ...
- this、target、currentTarget
this:绑定事件所触发行为的对象 target:最开始冒泡的的对象 currentTarget:事件触发行为的对象 this == target currentTarget和this 是target ...
- 破谣言——iPhone砍价
微信朋友圈和QQ空间很多朋友在传一个iPhone砍价免费送的活动.好吧,砍页面下面的那邪恶广告,第一感觉就是假的.但我要给出证明,所以就有了下面的代码.[只需把UID换成自己的就行],当你砍到5分钱的 ...