Just one shot. The probability of a bullet is a conditional probability, equal to the number of substrings 00 divided by 00 and 01 total (that is, the number of 0), the probability of the transfer of the bullet is equal to 0 of the ratio.
The number of substring 00 is a,0 B, then two probabilities are A/b and b/n respectively, the problem is to compare a*n and b*b.
#include <cstdio> #include <cstring>const int Maxn=105;char s[105];int cnt0,cnt1,cnt2,cnt3;int main () { while (scanf ("%s", s+1)!=eof) { cnt0=0; cnt2=0; cnt3=0; int Len=strlen (s+1); S[0]=s[len]; S[LEN+1]=S[1]; for (int i=1;i<=len;i++) { if (s[i]== ' 0 ') { cnt0++; if (s[i+1]== ' 0 ') cnt2++; if (s[i+1]== ' 1 ') cnt3++; } } if (cnt2*len==cnt0* (CNT2+CNT3)) printf ("equal\n"); else if (cnt2*len>cnt0* (CNT2+CNT3)) printf ("shoot\n"); else printf ("rotate\n"); } return 0;}
Uva1636-headshot (discrete probability)