Submit | All submissions | Best solutions | Back to list |
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
|
||||||||||||||
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 |
||||||||||||||
2017-10-11 12:10:25
what's meaning of "n:=" |
||||||||||||||
2017-10-08 08:23:03
AC in one go ;) . Just 2 lines of code in Python :D! |
||||||||||||||
2017-09-25 19:06:14
what is the meaning of ":=" operator |
||||||||||||||
2017-09-15 23:14:46
AC in one go : ) |
||||||||||||||
2017-08-17 07:56:33
cant we use hashing?? |
||||||||||||||
2017-08-15 17:59:24
try to find a pattern on copy for 1-10 . Then you can do this in O(1) time |
||||||||||||||
2017-07-18 15:55:04
Bit manipulation will do... there should'nt be any problem |
||||||||||||||
2017-07-08 13:30:37 Ravi Jangra
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 ? |
||||||||||||||
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 |