uva1636 - Headshot(条件概率)

本文探讨了条件概率的概念,并通过实例代码展示了如何计算特定条件下概率的计算过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

 

转载于:https://www.cnblogs.com/zywscq/p/4067706.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值