package com.reno.newwangyi; import java.util.Scanner; public class black { static long summy = 0; public static void same(long deep, long last, long maxdeep) { if (maxdeep == deep) { summy += last; return; } same(deep + 1, last, maxdeep); diff(deep + 1, last * 2, maxdeep); } public static void diff(long deep, long last, long maxdeep) { if (maxdeep == deep) { summy += last; return; } diff(deep + 1, last, maxdeep); same(deep + 1, last, maxdeep); } public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { summy=0; long n = sc.nextInt(); if (n == 1) { System.out.println(3); continue; } if (n == 2) { System.out.println(9); continue; } same(1, 1, n); long out = 3*summy; System.out.println(out); } } }
点赞 2

相关推荐

06-26 19:47
中南大学 Java
点赞 评论 收藏
分享
能干的三文鱼刷了100道题:公司可能有弄嵌入式需要会画pcb的需求,而且pcb能快速直观看出一个人某方面的实力。看看是否有面试资格。问你问题也能ai出来,pcb这东西能作假概率不高
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务