简单的条件概率题,直接再来一枪没子弹的概率是所有子串”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;
}

 

相关文章:

  • 2021-05-26
  • 2021-06-14
  • 2021-05-12
  • 2022-02-06
  • 2022-12-23
  • 2021-07-16
  • 2021-05-27
  • 2021-11-21
猜你喜欢
  • 2021-07-19
  • 2021-12-28
  • 2022-01-15
  • 2021-06-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-28
相关资源
相似解决方案