Submit | All submissions | Best solutions | Back to list |
BEENUMS - Beehive Numbers |
A beehive is an enclosed structure in which some honey bee species live and raise their young. In this problem we consider a two-dimensional sketch of the beehives. Each beehive is composed of a certain number of cells, where each cell is a regular hexagon. Each cell may have some neighbors, which are other cells that share a side with that cell. A cell with exactly 6 neighbors is an internal cell, while a cell with fewer neighbors is an external one. Notice that an external cell can always be changed to internal by adding some neighbor cells.
We are interested in a particular class of beehives. This class of valid beehives is defined recursively as follows: a) a single cell is a valid beehive; and b) given a valid beehive B, if we add the minimum number of cells such that each external cell of B becomes an internal cell, the result is a valid beehive.
The number of cells in a valid beehive is called a beehive number. Given an integer N, you must decide whether it is a beehive number.
Input
Each test case is described using a single line. The line contains an integer N (1 ≤ N ≤ 109). The end of input is indicated with a line containing a single −1.
Output
For each test case, output a single line containing an uppercase “Y” if N is a beehive number, or an uppercase “N” otherwise.
Example
Input: 43 1 7 19 15 -1 Output: N Y Y Y N
Added by: | Pablo Ariel Heiber |
Date: | 2010-09-26 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 NODEJS OBJC VB.NET |
Resource: | FCEyN UBA ICPC Selection 2010 |
hide comments
|
|||||||||||
2013-08-07 14:25:19 Sagar Grover
@Narendra Man you spoiled the question!!!! |
|||||||||||
2013-02-28 18:25:06 mystique_blue
Narendra's comment made the task even simpler though the test cases itself have simplified the job :) |
|||||||||||
2012-11-19 05:06:34 Paul Draper
Thank you Ivan Stošić. (Watch for overflow in intermediate calculations.) |
|||||||||||
2012-09-22 06:44:09 nikoo28
the test cases provided have made the problem very easy... |
|||||||||||
2012-04-17 11:10:32 spock
the problem setter can think about tightening the time limit. |
|||||||||||
2011-11-01 23:46:07 Miguel Oliveira
a simple solution does not need 64 bit numbers |
|||||||||||
2011-09-27 14:38:53 Ivan Sto¹iæ
Watch out for overflows :) I had to switch to 64 bit numbers before i got AC |
|||||||||||
2011-09-04 07:15:26 Chandan Giri
nice problem.. :) |