链接:核反应堆
题目难度并不大
提出值得注意的几点:
1)使用long来存放数据
2)打表
3)逗号与第二个数据之间有一个空格
4)推导公式:arr[i][0] = 3*H+2*L; arr[i][1] = H+L;
下面AC代码:
import java.util.Scanner;public class Main{private static Scanner scanner;private static long[][] arr;public static void main(String[] args) {scanner = new Scanner(System.in);//打表fun();while(scanner.hasNext()){int n = scanner.nextInt();if(n == -1){break;}System.out.println(arr[n][0]+", "+arr[n][1]);}}private static void fun() {arr = new long[34][2];long H = 1,L = 0;arr[0][0] = 1;for (int i = 1; i < arr.length; i++) {arr[i][0] = 3*H+2*L; arr[i][1] = H+L; //重新设定H,LH = arr[i][0];L = arr[i][1];}}
}