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
aashish_a2z: 2018-12-14 23:16:16

AC in one go...Observe the pattern.

piyushchavan88: 2018-12-14 18:41:12

Use mp boost library of c++ for input.
AC in one go!

daku5768: 2018-12-14 12:32:43

if anywhere in loop if n is divisible by 3 ,print NIE and return

laidactienbn: 2018-11-23 15:00:58

This is such an interesting prob.
All you need to do is to check out if n = 2^k, print TAK, else: NIE

priyanshu_pg: 2018-11-17 11:53:25

I am maintaining a set and checking whether the no has earlier occurred in set or not. In case a no repeats itself, I am breaking the loop for NIE. Still I am getting WA. Kindly help

knakul853: 2018-10-31 16:37:44

69th

aamir4813: 2018-10-17 07:50:22

very Easy Problem
AC in ONE GO


spoiler -
Just Think about Log2

adipat: 2018-10-09 14:46:58

Just run the loop and if at any point you find that n is divisible by 12, the loop will never terminate (12,6,3,12,6,3,..) pattern repeats. One other way is to check if the number is a power of 2, but I haven't tested this method.

ankit_mnnit: 2018-09-29 14:52:44

Only Check power of 2 or not

dewa251202: 2018-09-28 15:02:28

Testing my FTH


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