NYOJ之猴子吃桃问题

 

------------------------------------------------------

这道题有坑,实际上是(m+1)天,给的测试数据比测试结果少一天,加上按(m+1)天计算即可,估计出题的人自己代码写错了...

AC代码:

 1 import java.util.Scanner;
 2 
 3 public class Main {
 4 
 5     public static void main(String[] args) {
 6         
 7         Scanner sc=new Scanner(System.in);
 8         
 9         int times=sc.nextInt();
10         
11         while(times-->0){
12             int n=sc.nextInt();
13             System.out.println(solve(n));
14         }
15         
16     }
17     
18     public static int solve(int n){
19         int ans=1;
20         while(n-->0) ans=(ans+1)*2;
21         return ans;
22     }
23     
24 }

题目来源: http://acm.nyist.net/JudgeOnline/problem.php?pid=324

原文地址:https://www.cnblogs.com/cc11001100/p/5792304.html