比较简单的一道题目,统计00和01的个数之和为b(其实b也就是0的个数),统计00的个数为a,那么a/b就是rotate操作之后能够存活的概率,b/n(n代表的是可以装火药的位置个数)也就是shoot操作能够存活的概率,比较二者即可,具体实现见如下代码:
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<deque>
#include<functional>
using namespace std;
int main(){
string s;
while (cin >> s){
int n = s.size();
int a = 0, b = 0;//b 代表的是0的个数 a 代表的是00的个数
for (int i = 0; i < n; i++){
if (s[i] == '0'){
b++;
if (s[(i + 1) % n] == '0') a++;
}
}
if (a*n > b*b) cout << "SHOOT\n";
else if (a*n < b*b) cout << "ROTATE\n";
else cout << "EQUAL\n";
}
return 0;
}