import java.io.*; public class SesquinaryBinaryTree { public static void main(String[] args) throws IOException { PrintStream list = new PrintStream(new File("b344792.txt")); int height = Integer.parseInt(args[0]); SesquiTree tree = new SesquiTree(height); int index = 1; for(int i = 0; i < height; i++) for(int j = 1; j <= Math.pow(2, i);j++){ tree.WriteAtIndex(index); list.println(index + " " + tree.arr[index++]); } } } class SesquiTree { long[] arr; public SesquiTree(int rowCount){ arr = new long[(int)Math.pow(2, rowCount)]; } void WriteAtIndex(int index){ long term = arr[(int)Math.ceil((double)(index - 1)/2)] * 3 + (index %2 == 0 ? 0:1); while(term % 2 == 1) term = (long) Math.ceil(((double)term) * 1.5); arr[index] = term/2; } }