uva1636 - Headshot(条件概率)

简单的条件概率题,直接再来一枪没子弹的概率是所有子串”00“的数目除以‘0’的数目,随机转一下再打没子弹的概率是‘0’的数目除以总数目。

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<stack>
#include<queue>
#include<cctype>
#include<sstream>
using namespace std;
#define pii pair<int,int>
#define LL long long int
const int eps=1e-8;
const int INF=1000000000;
const int maxn=100000+10;
string s;
int a,b,n;
int main()
{
    //freopen("in8.txt","r",stdin);
    while(cin>>s)
    {
        a=b=0;
        n=s.length();
        for(int i=0;i<n;i++)
        {
            if(s[i]=='0')//这里注意‘0’不能写成0
            {
                b++;
                if((i<n-1&&s[i+1]=='0')||(i==n-1&&s[0]=='0'))//注意它是环形的!
                {
                   a++;
                }
            }
        }
        if(a*n>b*b) puts("SHOOT");
        else if(a*n<b*b) puts("ROTATE");
        else puts("EQUAL");
    }
    //fclose(stdin);
    //fclose(stdout);
    return 0;
}

 

posted @ 2014-11-01 20:40  周洋  阅读(267)  评论(0编辑  收藏  举报