Probability:
Probability of survival without spin = (total number of adjacent pair of zeros)/(total number of empty + bullets );
Probability of survival with spin/rotation = (total number of zeros)/(total number of empty + bullets );
SO, P_s_without_spin = total adjacent zero/length;
P_s_with_spinĀ = total zero/length;
if(P_s_without_spin == P_s_with_spin)
total adjacent zero/length = P_s_with_spinĀ = total zero/length;
From above relation,
total adjacent zero*length = total zero*total zero;
Here, (total adjacent zero*length) can be considered as P_s_without_spin in equal or in equal relations.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
#include <iostream> #include <cstdio> #include <cstring> using namespace std; int main() { char s[150]; int total_zero,pair_zero; int P_nspin,P_yspin; int len; while(scanf("%s",s)!=EOF) { len = strlen(s); total_zero=0; pair_zero=0; for(int i=0;i<len;i++) { if(s[i]=='0') { total_zero+=1; if(s[(i+1)%len]=='0') pair_zero+=1; } } P_nspin = pair_zero*len; P_yspin = total_zero*total_zero; if(P_nspin==P_yspin) cout<<"EQUAL\n"; else if(P_nspin>P_yspin) cout<<"SHOOT\n"; else cout<<"ROTATE\n"; } return 0; } |