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. Codeforces 930A. Peculiar apple-tree (dfs)

    题目: 代码: #include <bits\stdc++.h> using namespace std; ]; //b[i]表示距离1号花絮i步的花絮的个数 map <int, l ...

  2. EL与JSTL学习(一)EL技术

    1.EL 表达式概述 EL(Express Lanuage)表达式可以嵌入在jsp页面内部,减少jsp脚本的编写,EL出现的目的是要替代jsp页面中脚本的编写. 2.EL从域中取出数据(EL最重要的作 ...

  3. Activiti 23张表及7大服务详解

    7大服务介绍 服务名称 描述 RepositoryService Activiti 中每一个不同版本的业务流程的定义都需要使用一些定义文件,部署文件和支持数据 ( 例如 BPMN2.0 XML 文件, ...

  4. java 获取config 配置文件

    static ResourceBundle PropertiesUtil = ResourceBundle.getBundle("config"); public static S ...

  5. 学习参考《父与子的编程之旅python【第二版】》高清中文版PDF+高清英文版PDF+源代码

    对于初步接触编程语言的朋友,推荐看一看<父与子的编程之旅第2版>,对于完全编程零基础的很友好! 图文并茂,过多的文字堆垒很容易让人产生厌倦情绪,也更容易让人产生放弃的想法.使用了大量插图, ...

  6. JDBC读写MySQL的大字段数据

    JDBC读写MySQL的大字段数据   不管你是新手还是老手,大字段数据的操作常常令你感到很头痛.因为大字段有些特殊,不同数据库处理的方式不一样,大字段的操作常常是以流的方式 来处理的.而非一般的字段 ...

  7. man 7 glob

    GLOB(7) Linux Programmer's Manual GLOB(7) NAME glob - 形成路径名称 描述 (DESCRIPTION) 很久以前 在 UNIX V6 版 中 有一个 ...

  8. logstash-shipper.conf

    input { file { path => '/data/rsyslog/*/*/*.log' start_position => 'beginning' sincedb_path =& ...

  9. Python学习笔记-练习编写ATM+购物车(购物商城)

    作业需求: 模拟实现一个ATM + 购物商城程序: 1.额度 15000或自定义 2.实现购物商城,买东西加入 购物车,调用信用卡接口结账 3.可以提现,手续费5% 4.支持多账户登录 5.支持账户间 ...

  10. root用户删除文件提示:Operation not permitted

    root用户删除文件提示:Operation not permitted http://blog.csdn.net/evanbai/article/details/6187578