杭电2085核反应堆

题目:http://acm.hdu.edu.cn/showproblem.php?pid=2085
import java.util.Scanner;

public class 核反应堆2085 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
long[] gao = new long[35];//存高能质点数
long[] di = new long[35];//存低能质点数
gao[0] = 1;//0微秒时的射入的一个高能质点
gao[1] = 3;//第一微秒产生的高能质点
di[1] = 1;//第一微妙产生的低能质点
for (int i = 2;i <= 33;i++){
gao[i] = gao[i-1]*3+di[i-1]*2;//每微妙的高能质点数是上一秒高能质子数乘3加低能质子数乘2
di[i] = gao[i-1]+di[i-1];//没微妙的低能质子数等于上一微妙的高能质子数加低能质子数
}
while (input.hasNext()){
int n = input.nextInt();
if (n == -1){
break;
}
System.out.println(gao[n]+", "+di[n]);
}
}
}

猜你喜欢

转载自www.cnblogs.com/ztabk/p/12275139.html