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 ≤ 1014.
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
|
||||||||||||||
2016-10-24 09:12:06
For those who are getting WA for log(n)/log(2) Use log2(n)/log2(2) function.This is a new function in c/c++ for computing logarithm for float or double perfectly |
||||||||||||||
2016-10-17 09:32:37
use unsigned long long ,long int costed me two WA..simple logic..;) |
||||||||||||||
2016-10-12 13:37:44
long long won't be enough. use unsigned long long. very simple logic |
||||||||||||||
2016-10-11 09:07:35
FORGOT LONG LONG MISSED AC IN ONE :( |
||||||||||||||
2016-09-30 11:10:24 hacker_sk
n will be given always greater than 1 i.e. n >1, No need to worry about this. It's very easy of O(1) :) |
||||||||||||||
2016-09-15 00:19:30
changed long long to unsigned long long ..2 WA for taking long long ..:P |
||||||||||||||
2016-09-04 00:42:23
DO NOT LOOK AT COMMENT . THEY ONLY MAKE IT TOUGH FOR YOU. JUST USE YOUR OWN APPROACH AND SOLVE IT. THINK AND YOU WILL THEN FIND THE ANSWER. BUT IF YOU LOOK AT COMMENT . IT WOULD LOOK HARD. |
||||||||||||||
2016-08-04 19:08:01
long long int is enough..really very simple logic...use your pen n paper...AC in one go... |
||||||||||||||
2016-07-02 20:59:35
https://en.wikipedia.org/wiki/Collatz_conjecture |
||||||||||||||
2016-06-17 19:17:27
Was printing TAE instead of TAK... got me 2 WA lol.... |