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个星星的坐标.每个星星都有一个等级,数值等于坐标系内纵坐标和横坐标皆不大于它的星星的个数.星星的坐标按照纵坐标从小到大的顺序给出,纵坐标相同时 ...
随机推荐
- 为什么在3ds Max 按系统默认的快捷键AIT+W 视口最大化切换没反应?
经常使用3ds Max快捷键做效果图可谓是提高作图速度的毕竟之路,做效果图的朋友或许会遇到最大化视口显示失灵的问题,max默认快捷键为Alt+W,这里我不建议大家更改max的默认快捷键,当然Max也提 ...
- eclipse的maven工程视图切换
上面图切换成下面图: 点击eclipse右上角,如下图红圈,然后在选择javaEE这样就切换成javaEE视图了
- Vue学习之v-if与v-show的区别
v-if和v-show具有类似的功能,不过v-if才是真正的条件渲染,他会根据表达式适当的销毁或重建元素及绑定事件或子组件.若表达式初始值为false,则一开始元素或组件不会渲染,只有当第一次为真时, ...
- BZOJ1567 [JSOI2008]Blue Mary的战役地图(二分+二维hash)
题意 问边长为n的两个正方形中最大的相等子正方形.(n<=50) 题解 用到了二维hash,感觉和一维的不太一样. 对于列行有两个不同的进制数然后也是通过类似前缀和的方法差分出一个矩形的hash ...
- redis搭建与安装
redis提供五种数据类型:string,hash,list,set及zset(sorted set). 第一部分:安装redis 希望将redis安装到此目录 1 /usr/local/redis ...
- 洛谷 P1045 麦森数 (快速幂+高精度+算位数骚操作)
这道题太精彩了! 我一开始想直接一波暴力算,然后叫上去只有50分,50分超时 然后我改成万位制提高运算效率,还是只有50分 然后我丧心病狂开long long用10的10次方作为一位,也就是100亿进 ...
- 紫书 习题 11-1 UVa 821 (Floyd)
水题, Floyd一遍就完了. #include<cstdio> #include<algorithm> #define REP(i, a, b) for(int i = (a ...
- nginx proxy_set_header设置,自定义header
在实际应用中,我们可能需要获取用户的ip地址,比如做异地登陆的判断,或者统计ip访问次数等,通常情况下我们使用request.getRemoteAddr()就可以获取到客户端ip,但是当我们使用了ng ...
- Mysql 日期型,索引查询的问题
问题: 表中,有一个日期字段WorkDate(Date YYYY-MM-DD格式),现在我把它建成了索引,在检索条件时,WorkDate='YYYY-MM-DD' 时,用EXPLAIN分析,能看到使用 ...
- maven跳过单元测试-maven.test.skip和skipTests的区别以及部分常用命令
-DskipTests,不执行测试用例,但编译测试用例类生成相应的class文件至target/test-classes下. -Dmaven.test.skip=true,不执行测试用例,也不编译测试 ...