Submit | All submissions | Best solutions | Back to list |
COLONY - Linearian Colony |
Description
Linearians are peculiar creatures. They are odd in several ways:
- Every Linearian is either red or blue.
- A Linearian colony is a straight line, aligned N-S with the magnetic field.
- A colony starts with single red Linearian.
- Every year, each Linearian produces an offspring of the opposite color. After birth, the parent moves just south of the offspring. (Since everyone is born at once, this does make for a lot of jostling, but everyone stays in order.)
So a colony grows as follows:
N ----------- S Year 0: R Year 1: BR Year 2: RBBR Year 3: BRRBRBBR Year 4: RBBRBRRBBRRBRBBR
Given a year and a position along the N-S axis, determine what the color of the Linearian there will be.
Input
The first line is the year Y (0 <= Y <= 51).
The second line is the position P from north to south, 0-indexed (0 <= P < 2^Y).
Output
The color of the Linearian, either red or blue.
Input | Input |
---|---|
3 6 |
51 123456789012345 |
Output | Output |
blue |
red |
Added by: | BYU Admin |
Date: | 2013-10-18 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM32-GCC ASM64 MAWK BC C-CLANG NCSHARP CPP14 CPP14-CLANG COBOL COFFEE D-CLANG D-DMD DART ELIXIR FANTOM FORTH GOSU GRV JS-MONKEY JULIA KTLN NIM OBJC OBJC-CLANG OCT PICO PROLOG PYPY PYPY3 R RACKET RUST CHICKEN SQLITE SWIFT UNLAMBDA VB.NET |
hide comments
|
|||||||
2015-07-09 21:13:30 Vivek Mangal
didn't read 0-based indexing.costed too many WA. |
|||||||
2015-02-21 13:27:55 :.Mohib.:
Cake walk.... :) |
|||||||
2015-02-18 14:57:09 VIVEK GARG
Just manipulate with the indices correctly. |
|||||||
2014-12-13 21:30:37 devil
i keep getting WA...although my code is perfectly fine i hav checked it for all critical cases like 0 0, 51 2^51-1,51 2^51-3,etc |
|||||||
2014-12-02 17:39:01 Itachi_Uchiha
In 1 go! Last edit: 2014-12-03 10:22:51 |
|||||||
2014-11-14 09:16:34 .::Austin::.
using the logic similar to Indian Connection, giving WA here :( |
|||||||
2014-09-18 14:36:04 Nishanth Vijayan
DCEPC504 similar question. |
|||||||
2014-07-23 09:41:10 L
gud One........ |
|||||||
2014-07-21 13:31:06 rajul
really easy.. just read the ques carefully.. silly mistake costed 2 WA |
|||||||
2014-01-23 21:05:34 Piyush Raman Srivastava
0 index not 1 !! |