From af33d4221c0abb9f369f68f176d193498c07b0a2 Mon Sep 17 00:00:00 2001 From: Titouan Rigoudy Date: Fri, 26 Sep 2014 23:50:42 -0400 Subject: [PATCH] Solved Utopian Tree --- utopian_tree/test.in | 5 +++++ utopian_tree/utopian_tree.py | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 utopian_tree/test.in create mode 100644 utopian_tree/utopian_tree.py diff --git a/utopian_tree/test.in b/utopian_tree/test.in new file mode 100644 index 0000000..b84706e --- /dev/null +++ b/utopian_tree/test.in @@ -0,0 +1,5 @@ +4 +1 +2 +3 +4 \ No newline at end of file diff --git a/utopian_tree/utopian_tree.py b/utopian_tree/utopian_tree.py new file mode 100644 index 0000000..28729fa --- /dev/null +++ b/utopian_tree/utopian_tree.py @@ -0,0 +1,16 @@ +#!/usr/bin/python3 + +import sys + +def calcsize(cycles): + tmp = 2**((cycles+3)//2) + if cycles % 2 == 1: + return tmp - 2 + return tmp - 1 + +def main(): + total = int(sys.stdin.readline()) + for i in range(total): + print(calcsize(int(sys.stdin.readline()))) + +main() \ No newline at end of file