#include <stdio.h>
#include <string.h>
int gcd (int a,int b)//Ask for a A, B greatest common divisor
{
if (b==0)
return A;
Else
return gcd (B,A%B);
}
Char str[700000];
int main ()
{
int N,i,t,countu=0,len;
scanf ("%d", &n);
scanf ("%s", str);
Len=strlen (str);
for (i=0;i<len;i++)
{
if (str[i]== ' U ')
countu++;
if (str[i]== ' S ')
{
printf ("bingo\n");
return 0;
}
}
if (countu==0)//probability is 0
{
printf ("0\n");
return 0;
}
if (Countu==len)//probability is 1
{
printf ("1\n");
return 0;
}
T=GCD (Countu,len);
printf ("%d/%d", countu/t,len/t);//Simplification
}
/* Translation
As we all know, if you throw a coin and let it fall on the table, there are usually three kinds of results. Yes, believe me, it could be a face up, back up, or erect. You don't believe it, just try it. Some famous mathematicians have studied it in the past. They toss coins again and again. But Jacmy was a lazy man who was busy dating or playing games with girls and had no time to throw a coin 100,000 times. It was his idea to go to the bank and change thousands of dollars into coins and throw them only once. The only way to do this is to count the number of coins for three different results separately.
He showed you every coin on the table. Please tell him the probability of the coin facing up in the form of a score (when the probability is between 0.003 and 0.5), note that 1/2,50/100,33/66 is equal, but only 1/2 of the form can pass! If the probability is less than 0.003 or greater than 0.5, then tell him "Fail", of course, if you see a coin erected, output "Bingo" can be.
Input
There are two lines as input.
The first line is an integer N (1<n<65536) that represents the number of coins on the table.
The second line represents the n letters used to denote the direction of the coin, which are "U", "D", "S". "U" means face up, "D" means face down, "S" stands erect.
Output
If the experiment succeeds, the output has a positive upward probability. If it fails, the output "fail", if there is one or more "S", Output "Bingo"
*/
Nyoj 204 Coin Test