Utopian Tree
Utopian Tree The Utopian Tree goes through 2 cycles of growth every year. Each spring, it doubles in height. Each summer, its height increases by 1 meter. Laura plants a Utopian Tree sapling with a height of 1 meter at the onset of spring. How tall will her tree be after growth cycles? ----Solution-- import sys T = int(sys.stdin.readline()) for _ in range(T): N = int(sys.stdin.readline()) height = 1 for i in range(N): if i % 2 == 0: height *= 2 else: height += 1 print(height)
Comments
Post a Comment