Magic Mushrooms
InterviewTime limit2sMemory limit1024 MB
For each of N numbers, print Yes if it is a Fibonacci number (1, 1, 2, 3, 5, ...) and No otherwise.
- Level
Medium5 of 10
- Topics
- Math, Number theory
- Solved
- No attempts yet
Problem
On the planet Ruuk there is the Big Corporation of Little Fairies. Its fairies have long planted beds of magic mushrooms. From the first day the corporation existed, the fairies create one new bed every day. For two days after a new bed is made, its spores can be collected. After that, the bed produces only the mushrooms themselves.
If is the number of mushrooms planted on the bed created on day , then . The first and second days each had one mushroom, the third had two, the fourth had three, the fifth had five, and so on.
Magic mushrooms are the most valuable souvenirs a traveler can bring from Ruuk, so every visitor first looks for a magic mushroom bed. Lately, however, reports of fake magic mushrooms have become more frequent. A careful investigation showed that the Small Corporation of Big Fairies is behind them. It plants beds that look identical but are far less valuable. When it creates a bed, it plants a number of mushrooms that its rivals have never planted and will never be able to plant.
Write a program that, given the number of mushrooms on a bed, determines whether that bed is magic.
Input
The first line contains one integer (), the number of beds to check. Each of the next lines contains one integer , the number of mushrooms on a bed being checked. The input file is at most 1 MB.
Output
For each number in the input, print Yes if a bed with that many mushrooms is magic, and No otherwise. Print each answer on its own line.