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
2024-12-16 17:18:06
n & (n-1)
2021-11-18 15:43:50
y'all wildin
2021-11-11 07:04:23
its easy, we need to check the power of two

Last edit: 2021-11-18 15:57:36
2021-07-10 09:27:45
AC in one go :)
2021-05-30 13:10:04
make sure to put NIE not NE
2021-05-27 10:04:42
cant get a more simpler problem on spoj
2021-02-24 09:49:34
simple but tricky question.
2021-02-01 19:05:11
@sarveshjain967. Well I used 47 loops. Which is log2(10^14). That was enough for AC.
2020-11-27 18:56:20
__builtin_popcount = int
__builtin_popcountl = long int
__builtin_popcountll = long long
welcome
2020-08-04 14:22:48
Don't use __builtin_popcount here. I repeat don't use it.
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.