#C5025. Calculate Heads Probability
Calculate Heads Probability
Calculate Heads Probability
You are given a coin flipping experiment where you flip a coin N times. The result of each flip is either a head (H) or a tail (T). Your task is to determine the probability of getting heads as an irreducible fraction.
The probability is defined as ( \frac{\text{Number of Heads}}{N} ). You must reduce this fraction to its simplest form by dividing both the numerator and denominator by their greatest common divisor (GCD).
For example, if all flips result in heads, the probability is ( \frac{N}{N} = 1/1 ); if no flip results in heads, the probability is ( 0/1 ).
Note: Input is provided via STDIN and output should be printed to STDOUT.
inputFormat
The first line of input contains a single integer ( N ) (1 ≤ N ≤ 1000), representing the number of coin flips. The second line contains a string of length ( N ) consisting of the characters 'H' (for heads) and 'T' (for tails).
outputFormat
Output the probability of getting heads in the form of an irreducible fraction A/B.## sample
5
HHHHH
1/1