sdnu oj 1319 Russian Roulette

开始以为是俄罗斯轮盘, 仔细看看好像又不是,,,
注意如果 ROTATE 的话, 是随机旋转, 所以之后活下来的概率是 ‘0’ 的个数 / 总数
而 SHOOT 的话, 前一个是 ‘0’, 那么当前是 ‘0’ 就活, 否则死, 即 ‘00’ 生 ‘01’ 死, 活下来的概率是 ‘00’ / (‘00’ + ‘01’ )
再就是注意这是个圆的

#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
#include <math.h>
using namespace std;

typedef long long ll;
const int N = 10000006;

int main()
{
    int i, a, b, c;
    string s;
    while(cin >> s)
    {
        a = b = c = 0;
        int len = s.length();
        for(i = 0; i < len-1; ++i)
        {
            if(s[i] == '0')
            {
                ++c;
                if(s[i+1] == '0')
                    ++a;
                else
                    ++b;
            }
        }
        if(s[len-1] == '0')
        {
            ++c;
            if(s[0] == '0')
                ++a;
            else
                ++b;
        }
        if(c*(a+b) > a*len)
            printf("ROTATE\n");
        else if(c*(a+b) == a*len)
            printf("EQUAL\n");
        else
            printf("SHOOT\n");
    }
    return 0;
}

发布了40 篇原创文章 · 获赞 4 · 访问量 1132

猜你喜欢

转载自blog.csdn.net/xiongshuxian2019/article/details/104422673