시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 2228 897 728 41.671%

문제

헤일스톤 수열은 다음과 같이 정의 한다.

  • n이 짝수라면, 2로 나눈다.
  • n이 홀수라면, 3을 곱한 뒤 1을 더한다.

헤일스톤 추측은 임의의 양의 정수 n으로 수열을 시작한다면, 항상 4, 2, 1, 4, 2, 1,...로 끝난다는 추측이다. 이 문제에서는 1이 나오면 수열이 끝난 것으로 처리한다.

n이 주어졌을 때, 이 수열에서 가장 큰 값을 찾아 출력하는 프로그램을 작성하시오.

입력

첫째 줄에 테스트 케이스의 개수 T(1 ≤ T ≤ 100,000)가 주어진다. 다음 줄부터 T개의 줄에는 헤일스톤 수열의 시작값 n이 주어진다. (1 ≤ n ≤ 100,000)

출력

각각의 테스트 케이스에 대해서, n으로 시작하는 헤일스톤 수열에서 가장 큰 값을 출력한다.

예제 입력 1

4
1
3
9999
100000

예제 출력 1

1
16
101248
100000
W3sicHJvYmxlbV9pZCI6IjM5NDMiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWQ1ZTRcdWM3N2NcdWMyYTRcdWQxYTQgXHVjMjE4XHVjNWY0IiwiZGVzY3JpcHRpb24iOiI8cD5cdWQ1ZTRcdWM3N2NcdWMyYTRcdWQxYTQgXHVjMjE4XHVjNWY0XHVjNzQwIFx1YjJlNFx1Yzc0Y1x1YWNmYyBcdWFjMTlcdWM3NzQgXHVjODE1XHVjNzU4IFx1ZDU1Y1x1YjJlNC48XC9wPlxyXG5cclxuPHVsPlxyXG5cdDxsaT5uXHVjNzc0IFx1YzlkZFx1YzIxOFx1Yjc3Y1x1YmE3NCwgMlx1Yjg1YyBcdWIwOThcdWIyMDhcdWIyZTQuPFwvbGk+XHJcblx0PGxpPm5cdWM3NzQgXHVkNjQwXHVjMjE4XHViNzdjXHViYTc0LCAzXHVjNzQ0IFx1YWNmMVx1ZDU1YyBcdWI0YTQgMVx1Yzc0NCBcdWIzNTRcdWQ1NWNcdWIy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KSwgd2hpY2ggaXMgdGhlIHN0YXJ0aW5nIHZhbHVlLjxcL3A+XHJcbiIsIm91dHB1dCI6IjxwPkZvciBlYWNoIGRhdGEgc2V0IHRoZXJlIGlzIGEgc2luZ2xlIGxpbmUgb2Ygb3V0cHV0IGNvbnNpc3Rpbmcgb2YgdGhlIGRhdGEgc2V0IG51bWJlciwgYSBzaW5nbGUgc3BhY2UsIGFuZCB0aGUgbGFyZ2VzdCB2YWx1ZSBpbiB0aGUgc2VxdWVuY2Ugc3RhcnRpbmcgYXQgYW5kIGluY2x1ZGluZyBuLjxcL3A+XHJcbiIsImhpbnQiOiIiLCJvcmlnaW5hbCI6IjEiLCJwcm9ibGVtX2xhbmdfY29kZSI6Ilx1YzYwMVx1YzViNCJ9XQ==

출처

ACM-ICPC > Regionals > North America > Greater New York Region > 2012 Greater New York Programming Contest A번

  • 문제를 번역한 사람: baekjoon
  • 문제의 오타를 찾은 사람: degurii