uva1636 决斗

直接扣一枪是一个条件概率,因为他必须符合上一枪为0的这个条件,所以这一枪一维0的概率等于 子串00的总数除以 00加上01的总数(也就是0的全部个数)

如果转一下再扣为空,它的概率为0的个数除以子串长度.

设a等于子串00的个数,b 为0的个数

所以概率分别为p1 = a / b ,p2 = b / n;比较两个大小移向既得an 和 b*b比较.

注意子弹顺序是环形的 所以子串s[n-1] 后面s[n] = s[0];

/***********************************************
 * Author: fisty
 * Created Time: 2015/3/3 15:35:18
 * File Name   : uva1636.cpp
 *********************************************** */
#include <iostream>
#include <cstring>
#include <deque>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <cstdio>
#include <bitset>
#include <algorithm>
using namespace std;
#define Debug(x) cout << #x << " " << x <<endl
#define Memset(x, a) memset(x, a, sizeof(x))
const int INF = 0x3f3f3f3f;
typedef long long LL;
typedef pair<int, int> P;
#define FOR(i, a, b) for(int i = a;i < b; i++)
    
int main() {
    //freopen("in.cpp", "r", stdin);
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    while(cin >> s){
        int n = s.length();
        int b = 0, a = 0;
        s[n] = s[0];  //环形
        for(int i = 0;i < n; i++){    
            if(s[i] == '0'){
                b++;
            }
            if(s[i] == '0' && s[i+1] == '0'){
                a++;
            }
        }
        if(a*n > b*b){
            cout << "SHOOT" << endl;
        }else if(a*n < b*b){
            cout << "ROTATE" << endl;
        }else{
            cout << "EQUAL" << endl;
        }
        
    }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值