import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); while (in.hasNextInt()) { int n = in.nextInt(); int[] nodes = new int[3]; for (int i = 0; i < n; ++i) { nodes[i] = in.nextInt(); } Arrays.sort(nodes); System.out.println(commonRoot(1 << (n - 1), nodes)); } } private static int commonRoot(int root, int[] nodes) { if (nodes[0] == root || nodes[2] == root) { return root; } if (nodes[0] > root) { return commonRoot(root + root >> 1, nodes); } if (nodes[2] < root) { return commonRoot(root >> 1, nodes); } else { return root; } } }
点赞 评论

相关推荐

09-21 23:16
门头沟学院 Java
传奇逃兵王:招不起就别招,叽里咕噜说啥呢
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务