2018 多校6 hdu 6362 6370 6373

6362 a题 oval-and-rectangle

数学题 求周长的期望

一个数学题

(还不太会用markdown写数学公式

然后算期望除以b

注意精度不让四舍五入

学到了三种方法

一是减去精度的0.5,也就是减去精度下一位为5其他全为0的数(不太会说可看代码

二是先乘1e6,再除1000000.0;

三是用cout.precision()

ac代码:

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<map>
 4 #include <cmath>
 5 #include<cstring>
 6 #include<string>
 7 #include<cstdlib>
 8 #include<iomanip>
 9 #include<vector>
10 #include<queue>
11 using namespace std;
12 const double pi = acos(-1.0); 
13 
14 int main()
15 {
16     int t;
17     cin>>t;
18     while(t--)
19     {
20         int a,b;
21         cin>>a>>b;
22         double ans = 2 * b + pi * a;
23         //printf("%.7lf\n",ans);
24         ans = ans -0.0000005;
25         printf("%.6lf\n",ans);
26     }
27     return 0;
28 }
View Code

6370 i题 Werewolf

这道题题意是 村民只能讲真话,狼可以讲真话也可以撒谎,每种样例一定存在其中一种及以上情况,问能确定的村民和狼的编号分别是多少。

其实是个简单的思维题,对情况进行排列组合,写个表就出来了(不知道有没有更简单的方法,我不太玩狼人杀

思路是:当A说B是村民而B说A是狼时,A一定是狼。

    延申到a说b是村民,b说c是村民,c说d是村民……最后一个人说a是狼,那么a一定是狼。

    然后说狼是村民的一定是狼。

具体实现应该是用并查集

(明天补代码

6373 L题 Pinball

一个高中物理题hhh(虽然我高中物理挺差的

考虑以斜面和垂直斜面方向作为坐标轴(忘记了高中物理里叫什么方法了

只要判断每次s加上变化的路程有没有比x/cosΘ 大即可

ac代码:

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<map>
 4 #include <cmath>
 5 #include<cstring>
 6 #include<string>
 7 #include<cstdlib>
 8 #include<iomanip>
 9 #include<vector>
10 #include<queue>
11 using namespace std;
12 const double pi = acos(-1.0); 
13 const double g = 9.8;
14 
15 int main()
16 {
17     int t;
18     cin>>t;
19     while(t--){
20         double x, y, a, b;
21         cin>>a>>b>>x>>y;
22         int flag = 1;
23         double s = 0;
24         double p = sqrt(a * a + b * b);
25         double sita = acos(a / p);
26         double si = sin(sita);
27         double co = cos(sita);
28         double ta = b / a;
29         double v = sqrt(2 * g * (y - (b * (-1) * x / a)));
30         double gs = g * si;
31         double gc = g * co;
32         double maxn = (-1) * x / co;
33         double vs = v * si;
34         double vc = v * co;
35                 while(s < maxn){
36             double t = 2 * vc / gc;
37             s += vs * t + (gs * t * t / 2);
38             vs += gs * t; 
39             flag++;
40         }
41         cout<<flag-1<<endl;
42     }
43     return 0;
44 }
View Code

猜你喜欢

转载自www.cnblogs.com/moomight/p/11257405.html