• 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;
    }
  • 相关阅读:
    2021-5-14 日报博客
    2021-5-13 日报博客
    2021-5-11 日报博客
    2021-5-10 日报博客
    2021-5-8 周报博客
    团队介绍——北部大队
    周总结4
    梦断代码阅读笔记02
    周总结3
    周总结2
  • 原文地址:https://www.cnblogs.com/zhangmingzhao/p/6966071.html
Copyright © 2020-2023  润新知