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

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

hide comments
2018-03-15 15:05:34
AC in one go!!!
2018-03-14 11:51:58
successfully wasted an hour by using NIL against of NIE; but learned a new thing that some people says that their code fails at that test case etc.. so guys it's not that if u get wrong answer after any test case than it might be wrong, it may be your first test case, mine always fails at 20 so it's not that mine first 19 are all correct,
2018-03-14 07:44:30
Instead of maps and bruteforce it's fun to think of what's actually happening in the function itself...........try to generate a math formula such that,as soon as you substitute 'n' in your formula you should get the output....in other words try for a single liner...

Last edit: 2018-03-14 07:45:51
2018-02-15 12:37:33
AC in one go ;) just check for 1-10 cases and see the pattern if 3,6,12 occurs make the loop infinite
or use bits manipulation
2018-02-06 04:47:16
Look tutorial of bit manipulation.
2018-01-02 16:37:05
Weak test case :(
doesn't check when n=0.
2018-01-02 13:22:54
use unsigned long long.
3 WA for that.
look for the pattern
2017-12-14 11:16:47
":=" is "=". The colon is the misprint I guess.
2017-11-06 06:01:36
long long costed WA!
2017-10-18 13:18:54
if(n<=1) then stops
if(n>1) check if n is a power of two if yes then stops otherwise does not stops
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.