POJ 3869 条件概率

传送门:http://poj.org/problem?id=3869

题意:

就是电影中常见的轮回传枪对着自己脑子的赌命游戏,0代表没子弹,1代表有子弹 左轮枪的梭子是圆的,所以注意判断最后一个到第一个管连着的,循环之外判断下就行了。

然后就是条件概率了。对手没打出子弹,是0,找出00/00+01,随机来一发就是0/n。其实00+01就是0的数量,这里的01都是连续的。

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

typedef long long ll;

int main()
{
    string str;
    freopen("headshot.in","r",stdin);
    freopen("headshot.out","w",stdout);
    while(cin>>str)
    {
        int a=0,b=0,c=0;
        int n=str.length();
        for(int i=0; i<n-1; i++)
        {
            if(str[i]=='0'&&str[i+1]=='0')
                a++;
            if((str[i]=='0'&&str[i+1]=='0')||(str[i]=='0'&&str[i+1]=='1'))
                c++;

            if(str[i]=='0')
                b++;
        }
        if(str[n-1]=='0')
            b++;
        if(str[n-1]=='0'&&str[0]=='0')
            a++;
        if((str[n-1]=='0'&&str[0]=='0')||(str[n-1]=='0'&&str[0]=='1'))
            c++;
        if(a*n>b*c)
            cout<<"SHOOT"<<endl;
        else if(a*n<b*c)
            cout<<"ROTATE"<<endl;
        else
            cout<<"EQUAL"<<endl;
    }
    return 0;
}

 

转载于:https://www.cnblogs.com/zhangmingzhao/p/6966071.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值