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 ...
随机推荐
- 【RF库Collections测试】Get From Dictionary
Name:Get From DictionarySource:Collections <test library>Arguments:[ dictionary | key ]Returns ...
- 对double数据类型的数据保留两位小数,并且进行四舍五入
1.代码如下: /** * 对double数据类型的数据 保留两位小数,并且进行四舍五入 * @author Administrator */ public class Main { // 工具类 p ...
- OnGlobalLayoutListener用法
1.implements ViewTreeObserver.OnGlobalLayoutListener{} 2.mContentView.getViewTreeObserver().addOnGlo ...
- 在lampp的proftpd下新增FTP用户的方法与配置
用LAMPP的安装方法可以开一个默认的lampp用户,不过多用户怎样管理.目录怎样设置?这里简明说一下. 要求:使用Lampp的proftpd,开通多个FTP用户,并各分配一个目录,而且需要限制用户在 ...
- JS中保留小数位数
一.1.2.toFixed(2)
- php查询操作实现投票功能
这篇文章主要为大家详细介绍了php查询操作实现投票功能的具体代码,具有一定的参考价值,感兴趣的小伙伴们可以参考一下 本文实例为大家分享了php查询操作实现投票功能的代码,供大家参考,具体内容如下 ...
- Excel ALT+小键盘的妙用
用法就是摁住ALT不松,然后输入小键盘数字(一定要小键盘),再松开ALT就可以了 α ALT+42689β ALT+42690γ ALT+42691δ ALT+4269 ...
- jfinal怎么给model增加自定义的字段作为DTO?
简单的可以使用: List<Record> docList = myService.findSuperviseFile(type,id); for(Record record : docL ...
- Oracle性能优化之 Oracle里的优化器
优化器(optimizer)是oracle数据库内置的一个核心子系统.优化器的目的是按照一定的判断原则来得到它认为的目标SQL在当前的情形下的最高效的执行路径,也就是为了得到目标SQL的最佳执行计划. ...
- mysql-blog
https://www.cnblogs.com/zhanht/p/5450559.html