WILLITST - Will it ever stop


When Bob was in library in University of Warsaw he saw on one of facades caption :"Will it ever stop?" and below some mysterious code:

while n > 1
  if n mod 2 = 0 then
    n:=n/2
  else
    n:=3*n+3

Help him finding it out !

Input

In first line one number n<=10^14.

Output

Print "TAK" if program will stop, otherwise print "NIE"

Example

Input:
4

Output:
TAK

hide comments
deepak1228: 2016-12-21 18:11:49

https://www.hackerearth.com/practice/notes/bit-manipulation/
wanna learn something new from this question go through above link :)
in o(1) time......ac

apurvgs: 2016-12-20 14:41:20

easy problem,,just if condition and bit manipulation

Last edit: 2016-12-24 13:27:44
scorpion_ajay: 2016-12-19 17:02:38

use your pen :p

humble_fool: 2016-12-09 07:53:15

AC in one go. Bits manipulation is the key. Although you can do it using log2 but try Bits Manipulation, you will learn something new. :)

spartax: 2016-11-30 07:07:47

HINT: if n is a power of 2, it gets reduced to 1. and if n is not a power of 2, then if n is even, it becomes odd. Think what happens to odd integers and you'll get theta(1) solution :-)

radeonguy: 2016-11-28 18:29:04

HINT : you may want to use double instead of float if using log2

mohitgupta07: 2016-11-17 10:21:02

Donot use that log function. It will give you wa... find another way to get power of 2. umm... how about bit manipulation ;)

aditya_rev: 2016-11-03 18:01:28

ez as brainf##ck

sudiptob2: 2016-10-24 09:12:06

For those who are getting WA for log(n)/log(2)
Use log2(n)/log2(2) function.This is a new function in c/c++ for computing logarithm for float or double perfectly

d_pawan_kumar: 2016-10-17 09:32:37

use unsigned long long ,long int costed me two WA..simple logic..;)


Added by:Krzysztof Lewko
Date:2011-11-09
Time limit:0.906s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:AMPPZ 2011