Headshot

Time Limit: 1000ms
Memory Limit: 65536KB

This problem will be judged on PKU. Original ID: 3869
64-bit integer IO format: %lld      Java class name: Main

You have a revolver gun with a cylinder that has n chambers. Chambers are located in a circle on a cylinder. Each chamber can be empty or can contain a round. One chamber is aligned with the gun's barrel. When trigger of the gun is pulled, the gun's cylinder rotates, aligning the next chamber with the barrel, hammer strikes the round, making a shot by firing a bullet through the barrel. If the chamber is empty when the hammer strikes it, then there is no shot but just a "click". 
You have found a use for this gun. You are playing Russian Roulette with your friend. Your friend loads rounds into some chambers, randomly rotates the cylinder, aligning a random chamber with a gun's barrel, puts the gun to his head and pulls the trigger. You hear "click" and nothing else - the chamber was empty and the gun did not shoot. 
Now it is your turn to put the gun to your head and pull the trigger. You have a choice. You can either pull the trigger right away or you can randomly rotate the gun's cylinder and then pull the trigger. What should you choose to maximize the chances of your survival?

 

Input

The input file contains a single line with a string of n digits "0" and "1" (2 <= n <= 100). This line of digits represents the pattern of rounds that were loaded into the gun's chambers. "0" represent an empty chamber, "1" represent a loaded one. In this representation, when cylinder rotates before a shot, the next chamber to the right gets aligned with the barrel for a shot. Since the chambers are actually located on a circle, the first chamber in this string follows the last one. There is at least one "0" in this string.

 

Output

Write to the output file one of the following words (without quotes):

"SHOOT" - if pulling the trigger right away makes you less likely to be actually shot in the head with the bullet (more likely that the chamber will be empty). 
"ROTATE" - if randomly rotating the cylinder before pulling the trigger makes you less likely to be actually shot in the head with the bullet (more likely that the chamber will be empty). 
"EQUAL" - if both of the above choices are equal in terms of probability of being shot.

 

Sample Input

Sample Input #1:
0011 Sample Input #2:
0111 Sample Input #3:
000111

Sample Output

Sample Output #1:
EQUAL Sample Output #2:
ROTATE Sample Output #3:
SHOOT

Source

解题:英语阅读题。。。。条件概率什么的,意思就是当前是0了,那么后面是00的概率是多少,如果选择旋转,那么旋转得到0的概率又是多少,然后比较概率大小即可

 #include <cstdio>
#include <cstring>
using namespace std;
const int maxn = ;
char str[maxn];
int main() {
while(~scanf("%s",str)) {
int len = strlen(str),a = ,b = ,c = ;
for(int i = ; i < len; ++i)
if(str[i] == '') {
if(str[(i+)%len] == '') a++;
else if(str[(i+)%len] == '') b++;
} else c++;
if(len*a == (len - c)*(a + b)) puts("EQUAL");
else if(len*a < (len - c)*(a + b)) puts("ROTATE");
else puts("SHOOT");
}
return ;
}

POJ 3869 Headshot的更多相关文章

  1. POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理

    Halloween treats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7644   Accepted: 2798 ...

  2. POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理

    Find a multiple Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7192   Accepted: 3138   ...

  3. POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治

    The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22286 ...

  4. POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法

    Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 37427   Accepted: 16288 Descr ...

  5. POJ 3254. Corn Fields 状态压缩DP (入门级)

    Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9806   Accepted: 5185 Descr ...

  6. POJ 2739. Sum of Consecutive Prime Numbers

    Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20050 ...

  7. POJ 2255. Tree Recovery

    Tree Recovery Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11939   Accepted: 7493 De ...

  8. POJ 2752 Seek the Name, Seek the Fame [kmp]

    Seek the Name, Seek the Fame Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 17898   Ac ...

  9. poj 2352 Stars 数星星 详解

    题目: poj 2352 Stars 数星星 题意:已知n个星星的坐标.每个星星都有一个等级,数值等于坐标系内纵坐标和横坐标皆不大于它的星星的个数.星星的坐标按照纵坐标从小到大的顺序给出,纵坐标相同时 ...

随机推荐

  1. maven/ssm框架搭建

    好久没有写java了,昨天学了下maven,不用手动的下载和添加jar包,实在是太方便. ------------------------------------------------------- ...

  2. HOJ 1867 经理的烦恼 【 树状数组 】

    题意:给出一个区间,求这个区间里面素数的个数 这道题wa了好多次---是因为add操作没有写对 每次更新的时候,应该先判断没有加上y是不是质数,加上了y是不是质数 如果从质数变成不是质数,那么add( ...

  3. 3ds Max制作碗实例教程

    一. 碗的建模.模型的结果如图WB—1所示: 图WB—1 1. 创建圆柱,并调节参数,转换到多边形,最终的结果图WB—2所示: 图WB—2 2.使用Inset(插入)插入一个面,再次执行Extrude ...

  4. NetworkX-根据权重画图

    load_data = sio.loadmat(load_path) #阈值处理 mat=np.array(load_data['R']) mat[mat<0]=0 mat[mat<0.4 ...

  5. .startsWith和endsWith的使用方法与说明

    a.startsWith(b) --判断字符串a,是不是以字符串b开头 a.endsWith(b) --判断字符串a,是不是以字符串b结尾

  6. How Javascript works (Javascript工作原理) (四) 事件循环及异步编程的出现和 5 种更好的 async/await 编程方式

    个人总结: 1.讲解了JS引擎,webAPI与event loop合作的机制. 2.setTimeout是把事件推送给Web API去处理,当时间到了之后才把setTimeout中的事件推入调用栈. ...

  7. spring慕课网

    资源链接 http://spring.io/ http://projects.spring.io/spring-framework/ Spring是什么? Spring是一个开源的轻量级的应用开发框架 ...

  8. HTML一些标记

    4)a标签也可以转换样式为按钮 <a class="btn btn-primary" href="#" role="button"&g ...

  9. WPF 内部的5个窗口之 MediaContextNotificationWindow

    原文:WPF 内部的5个窗口之 MediaContextNotificationWindow 本文告诉大家在 WPF 内部的5个窗口的 MediaContextNotificationWindow 是 ...

  10. php通过shell调用Hadoop的方法

    1.php代码(index.php) <!DOCTYPE html> <html> <!-- <style> body{background-color:re ...