题意:你和人决斗。决斗规则如下:用一把有n个弹槽的左轮手枪,对着自己脑袋来一枪,孰生孰死看天意。现在对方已经装了若干发子弹,并随机转了一下转轮,子弹呢用一个01序列表示,0表示这个弹槽无子弹,1表示有子弹。对方先对着自个脑袋开了一枪,嗯,你只听到了一声’click’,人还好好的,是空枪。现在轮到你了,摆在你面前的有两个选择,一是直接对自己开射,二是转一下转轮再来开射,显然你会选择生还希望更大的那种。
现在要做的就是根据子弹装填的序列,进行判断,如果直接shot生还希望大输出”SHOOT”,如果转一下生还希望大输出”ROTATE”,两种选择生还希望相同输出“EQUAL”。
思路:简单的计算概率,然后比较就可以了。
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define MAXN 100100
#define MAXE 100
#define INF 100000000
#define MOD 10001
#define LL long long
#define ULL unsigned long long
#define pi 3.14159
using namespace std;
int main() {
std::ios::sync_with_stdio(false);
string str;
while (cin >> str) {
int ans1 = 0;
int ans2 = 0;
for (int i = 0; i < str.length(); ++i) {
if (i == str.length() - 1) {
if (str[i] == '0' && str[0] == '0')
ans1++;
} else {
if (str[i] == '0' && str[i + 1] == '0')
ans1++;
}
if (str[i] == '0')
ans2++;
}
if (ans1 * (int) str.length() > ans2 * ans2) {
cout << "SHOOT\n";
} else if (ans1 * (int) str.length() < ans2 * ans2) {
cout << "ROTATE\n";
} else {
cout << "EQUAL\n";
}
}
return 0;
}
/*
0011
0111
000111
*/