zoukankan      html  css  js  c++  java
  • 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;
    }
  • 相关阅读:
    论语心得
    水果总结
    欢乐颂
    大牌驾到
    Excel补全日期(日期按顺序补全)
    c语言define和typedef区别和使用
    c语言寄存器变量
    c语言伪常量const理解
    c语言静态断言-定义自己的静态断言
    c语言静态断言
  • 原文地址:https://www.cnblogs.com/zhangmingzhao/p/6966071.html
Copyright © 2011-2022 走看看