POJ 3869 Headshot
Headshot
This problem will be judged on PKU. Original ID: 3869
64-bit integer IO format: %lld Java class name: Main
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
Output
"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的更多相关文章
- POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理
Halloween treats Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7644 Accepted: 2798 ...
- POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理
Find a multiple Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7192 Accepted: 3138 ...
- POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治
The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22286 ...
- POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法
Flip Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 37427 Accepted: 16288 Descr ...
- POJ 3254. Corn Fields 状态压缩DP (入门级)
Corn Fields Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9806 Accepted: 5185 Descr ...
- POJ 2739. Sum of Consecutive Prime Numbers
Sum of Consecutive Prime Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20050 ...
- POJ 2255. Tree Recovery
Tree Recovery Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11939 Accepted: 7493 De ...
- 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 ...
- poj 2352 Stars 数星星 详解
题目: poj 2352 Stars 数星星 题意:已知n个星星的坐标.每个星星都有一个等级,数值等于坐标系内纵坐标和横坐标皆不大于它的星星的个数.星星的坐标按照纵坐标从小到大的顺序给出,纵坐标相同时 ...
随机推荐
- cuda windows运行时间限制
GTX1080的卡,8G的显存,写cuda时申请了2G的显存就莫名其妙的抛异常,昨天找了一天也没找出bug,去stackoverflow上问了下才知道是windows的事,需要修改注册表.问题链接 - ...
- FCC编程题之中级算法篇(中)
介绍 接着上次的中级算法题 目录 1. Missing letters 2. Boo who 3. Sorted Union 4. Convert HTML Entities 5. Spinal Ta ...
- Debian9.5系统DNS服务器BIND软件配置说明
DNS的出现的历史 网络出现的早期是使用IP地址通讯的,那时就几台主机通讯.但是随着接入网络主机的增多,这种数字标识的地址非常不便于记忆,UNIX上就出现了建立一个叫做hosts的文件(Linux和W ...
- h5实现 微信的授权登录
本文重点 判断是不是微信环境 localstorage设置一个值 微信授权登录 获取一个时间戳 new Date().getTime() const wx = (function () { retur ...
- 计算 List 数据的属性值的总和
List<PostRushPretreatmentMember> taskMember = pre.getTaskMember();///成员分配情况 Integer taskOrderN ...
- POJ 1742 Coins(多重背包?)
题解 一个自然的思路是对于每一个物品做一次01背包 然后T飞了. 试着用二进制拆分,还是T了. 单调队列,对不起,懒,不想写. 我们这样想.设dp[i]代表i这个面值前几种硬币是否能凑到 然后对于每一 ...
- SPOJ 962 Intergalactic Map
Intergalactic Map Time Limit: 6000ms Memory Limit: 262144KB This problem will be judged on SPOJ. Ori ...
- 通过案例快速学会Picasso图片缓存库
picasso是Square公司开源的一个Android图形缓存库,官网地址http://square.github.io/picasso/,可以实现图片下载和缓存功能. 下载地址:ht ...
- Qt之图形(渐变填充)
简述 QGradient可以和QBrush组合使用,来指定渐变填充. Qt目前支持三种类型的渐变填充: QLinearGradient:显示从起点到终点的渐变. QRadialGradient:以圆心 ...
- hdoj 1719 Friend
Friend Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Sub ...