1636

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.

#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;
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *