More than 2018 school 6 hdu 6362 6370 6373

6362 a题 oval-and-rectangle

Math find the circumference of expectations

A math problem

(Also less likely to write a mathematical formula with markdown

Then divided by the expected count b

Note not to rounding precision

I learned three methods

One minus accuracy of 0.5, which is at minus accuracy of a whole number of other 5 0 (do not speak can look at the code

Second, first by 1e6, and then in addition to 1,000,000.0;

Third, with cout.precision ()

ac Code:

 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

This question is the meaning of the questions the villagers can only speak the truth, the wolf may also lie to tell the truth, there must be one for each sample and the above, the number and asked the villagers and wolves were able to determine how much.

In fact, the question is a simple way of thinking, the situation permutations and combinations, write a list came out (do not know if there was an easier way, I do not play to kill the werewolf

The idea is: When A and B, said B villagers say that A is a wolf, A must be the wolf.

    Extended to apply to the villagers a say b, b and c is said that the villagers, the villagers ...... c d say the last person to say a wolf, then it must be a wolf.

    Then Wolf said the villagers must be wolves.

Specific implementation should be a disjoint-set

(Code up tomorrow

 

6373 L title Pinball

A high school physics problem hhh (though my high school physics very poor

Consider slope and slope direction as the vertical axis (forget the high school physics in any way called

Analyzing each s plus long distance there is no change ratio x / cosΘ be larger

ac Code:

 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

 

Guess you like

Origin www.cnblogs.com/moomight/p/11257405.html