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
|
rv111:
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,
|
|
eddie_codes:
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 |
|
quock:
2018-02-06 04:47:16
Look tutorial of bit manipulation. |
|
true_idiot:
2018-01-02 16:37:05
Weak test case :(
|
|
akhand_mishra:
2018-01-02 13:22:54
use unsigned long long.
|
|
sophozaar:
2017-12-14 11:16:47
":=" is "=". The colon is the misprint I guess. |
|
metahost:
2017-11-06 06:01:36
long long costed WA! |
|
themast3r:
2017-10-08 08:23:03
AC in one go ;) . Just 2 lines of code in Python :D! |
|
shubham9261:
2017-08-17 07:56:33
cant we use hashing?? |
|
softxide:
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 |
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 |