The second time in my life to participate in codeforces, compared to the last time the water was sent, this time it turned into water two hair ..
Competition link: Click to open the link
The first question is great... However, it is still because you have not noticed that the question of Getline () and getchar () is broken once. Hack ..
#include <iostream>#include <string>#include <cstdio>using namespace std;int main(){string tar;int testcase;cin>>testcase;getchar();while(testcase--){getline(cin,tar);//cout<<tar<<endl;if(tar=="miao."){cout<<"Rainbow's"<<endl;}else if(tar=="lala."){cout<<"Freda's"<<endl;}else{if(tar.find("miao.",0)==0 && tar.find("lala.",0)==string::npos){cout<<"Rainbow's"<<endl;}else if(tar.find("miao.",0)==string::npos && tar.find("lala.",0)==tar.length()-5){cout<<"Freda's"<<endl;}else{cout<<"OMG>.< I don't know!"<<endl;}} }return 0;}
The second question is purely a mathematical question, and the IQ is very self-defeating .. Looking for expectation, I read it for dozens of minutes without looking at the conditional probability. In this example, the final result is 2/3 .. Because it takes turns. The probability model is as follows:
Party A and Party B start shooting a target independently in turn. The winner wins the target first. Party A's probability of winning is P and Party B is Q.
This model is the sum of the infinite equi-ratio series.
Probability of A's victory = A's first victory + A's second victory + A's third victory +... (added to infinity)
A. The probability of winning the first shot is P.
The probability of winning the second shot (1-p) (1-Q) P (in the case that both the first shot and the second shot were absent .)
The probability of winning the third shot (1-p) ² (1-Q) ² P (the fifth shot when none of the first four attempts were made .)
The probability of winning a fifth shot (1-p) When (1-Q) when P (in the case that none of the first six times were shot by a and B .)
And so on...
Then, the summation formula Sn = a percentile/(1-Q) = p/(p + Q-PQ) is used for the infinitely proportional series)
Note: q = (1-p) (1-Q)
It's easy to say:
# Include <iostream> # include <cmath> # include <cstring> using namespace STD; const long Fab = 1000000; int main () {double A; Double B; int T1, t2, T3, T4; CIN> T1> T2> T3> T4; A = T1 * 1.0/T2; B = T3 * 1.0/T4; cout <A/(a + B-a * B) <Endl; // conditional probability ~ Return 0 ;}
The third question was originally a train of thought, but it was difficult .. Because I didn't understand what it meant .. Sure enough, water explosion