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 ≤ 1014.
Output
Print "TAK" if program will stop, otherwise print "NIE"
Example
Input: 4 Output: TAK
hide comments
|
amulyagaur:
2017-07-18 15:55:04
Bit manipulation will do... there should'nt be any problem |
|
Ravi Jangra:
2017-07-08 13:30:37
why bit manipulation is not showing correct answer. @admin Can you see why straight forward bit manipulation does not work but while loop with same concept works ? |
|
bhawna_123:
2017-07-02 06:59:34
Using a simple while loop is giving answer,but when I am using bit manipulation it is showing wrong answer |
|
wannacry123:
2017-06-11 16:41:09
Using unsigned long long int is the key
|
|
yank:
2017-06-03 05:36:50
:) happy AC Last edit: 2017-06-03 05:37:41 |
|
senacoder111:
2017-05-24 17:57:13
Instead of thinking for which number will loop stop,think for which situation the loop will stop. |
|
ayushgupta1997:
2017-05-20 06:52:18
ac in one go! simply try to figure out from 1 to 10 using pen and no need of unsigned long long and bit manipulation,while loop will do ur job.
|
|
newbie_127:
2017-05-17 15:45:07
AC in one go .
|
|
bharat190991:
2017-04-27 05:49:05
if the loop is infinite then it will repeat the pattern so no need of any bit manipulation. hope it will help. |
|
rohit659:
2017-03-15 08:41:02
use unsigned long long int , long long int costed me WA |
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 |