当前位置: 代码迷 >> 综合 >> HDOJ 2085 核反应堆
  详细解决方案

HDOJ 2085 核反应堆

热度:79   发布时间:2023-10-21 20:30:40.0

HDACM2085
注意范围即可

import java.util.Scanner;public class Main{public static void main(String[] args) {Scanner sc = new Scanner(System.in);while (sc.hasNext()) {int n = sc.nextInt();if (n==-1) {break;}long h = 1;long l = 0;long ht = 0;long lt = 0;while (n-->0) {ht = 3*h+2*l;lt = h+l;h = ht;l = lt;}System.out.println(h+", "+l);}}
}