Algorithm


problem link- https://www.spoj.com/problems/WILLITST/

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

 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming

#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <map>

using namespace std;

int main(){
unsigned long long t=0;
cin>>t;
if ((t&(t-1))==0){
	cout<<"TAK"<<endl;
}
else cout<<"NIE"<<endl;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
4

Output

x
+
cmd
TAK
Advertisements

Demonstration


SPOJ Solution-Will it ever stop-Solution in C, C++, Java, Python

Previous
SPOJ Solution - Test Life, the Universe, and Everything - Solution in C, C++, Java, Python