Uva1636-headshot (discrete probability)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.