Fizz and Buzz
시간 제한2초메모리 제한256 MB
3, 5, 또는 둘 다로 나누어지는 수들로 이루어진 수열이 주어질 때, 각 위치의 수가 3의 배수 집합에서 뽑혔는지 5의 배수 집합에서 뽑혔는지 추측하되 오류를 1200개 이하로 유지한다.
문제
Two dwarves, Fizz and Buzz, compose a sequence of integers. Each element is constructed as follows. First, the friends toss a fair coin to choose who will create the next number: with probability it will be Fizz, and with probability it will be Buzz. After that, if the toss was in favor of Fizz, he considers all integers from to divisible by and selects one of them at random. All these integers have the same probability of being selected. If the toss was in favor of Buzz, he considers all integers from to divisible by and selects one of them at random. All these integers also have the same probability of being selected. All coin tosses and all integer selections are independent events.
The dwarves composed a sequence of integers by the rules outlined above. Given the resulting sequence, guess who created which number, and do not make too many errors in the process.
입력
The first line contains an integer , the length of the sequence (). The second line contains the sequence itself: the integers , , , (). It is guaranteed that the sequence was composed according to the problem statement using a random number generator.
출력
Print a single line with characters each of which is either "F" or "B". In the perfect answer, the character at position must be "F" if the number was created by Fizz, or "B" if the number was created by Buzz. Your answer can contain at most errors. In other words, it can differ from the perfect answer at no more than positions.
힌트
The example above shows the perfect answer. In this example, the solution can not make more than ten errors, so any correctly formatted answer will be accepted.