GUESSTHE - Guess the Number
You are playing the funny game “Guess the number” with a friend. In this game, one of the
players choose a positive integer and the other has to guess it by using the clues that are
revealed. The i-th clue is either “Y” or “N” indicating whether the hidden number is a multiple
of i or not, respectively. For instance, if the clues so far are “YYNYY” it means that the number
is a multiple of 1, 2, 4 and 5, but it is not a multiple of 3. Given the clues of the game so
far, you have to guess the minimum possible number according to them, or call your friend a
cheater if there is no number such that the clues were correctly given.
The input contains several test cases. Each test case is described in a single line that contains
a non-empty string of at most 20 characters. The string is formed entirely of uppercase letters
“Y” and “N”, and represents the clues given so far, in order from left to right. The last line of
the input contains a single asterisk and should not be processed as a test case.
For each test case output a single line with the minimum positive integer that satisfies all the
clues, or −1 if there is no such a number.
nice problem finally gcd function give ac
AC 0.00 Easy one! ;)Last edit: 2016-01-30 07:40:06
ac in 0.01 with long long
So, here's the tip :
RADHE SHYAM LODHI:
Take care of the case when the string consists of only 'Y' repeatedly or only 'N' repeatedly. Cost me 2 NZEC and 15 mins.
@headfirstcoder: There are at max 20 characters only. Problem may arise if you are not considering \0 in character array.
Completed Double century by some guess work ... :P
No use of long long int..
AC after lot of WA's cause of silly mistake..