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
ambuj2512: 2019-05-25 21:02:06

very simple no need for for any bitwise and condition just take a array and check whether number repeat or not . :)

hetp111: 2019-04-25 18:09:50

Last edit: 2019-04-25 19:52:22
klmo: 2019-04-19 18:58:58

Anyone getting WA when using BigInteger and BigInteger.and() in java to check if n=2^k ?

stormborn_: 2019-03-29 12:23:32

why is log floor and ceil combination giving wrong ans in c

rahulrawat09: 2019-03-22 19:02:40

if(n>1&&ceil(log2(n))==floor(log2(n)))
cout<<"TAK";
else
//not gonna spoil main part XD

ramnarayanaram: 2019-01-23 17:06:48

c++ just two lines of code ,
think the advantage of floor,ceil function and logarithm.

anirudhg: 2019-01-17 14:18:59

hint : Use Bitwise & operator to check if n is of form 2^m.
https://codegeeksblog.wordpress.com/2013/06/02/spoj-willitst-will-it-ever-stop/

as10071999: 2019-01-14 19:19:21

Check For case <=1 and simple logic

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!


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