标签:
"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 #1: 0011 Sample Input #2: 0111 Sample Input #3: 000111
Sample Output #1: EQUAL Sample Output #2: ROTATE Sample Output #3: SHOOT
解题:英语阅读题。。。。条件概率什么的,意思就是当前是0了,那么后面是00的概率是多少,如果选择旋转,那么旋转得到0的概率又是多少,然后比较概率大小即可
1 #include <cstdio> 2 #include <cstring> 3 using namespace std; 4 const int maxn = 1000; 5 char str[maxn]; 6 int main() { 7 while(~scanf("%s",str)) { 8 int len = strlen(str),a = 0,b = 0,c = 0; 9 for(int i = 0; i < len; ++i) 10 if(str[i] == ‘0‘) { 11 if(str[(i+1)%len] == ‘0‘) a++; 12 else if(str[(i+1)%len] == ‘1‘) b++; 13 } else c++; 14 if(len*a == (len - c)*(a + b)) puts("EQUAL"); 15 else if(len*a < (len - c)*(a + b)) puts("ROTATE"); 16 else puts("SHOOT"); 17 } 18 return 0; 19 }
标签:
原文地址:http://www.cnblogs.com/crackpotisback/p/4618419.html