通项公式:
import java.util.*; public class Main { public static void main(String[] args) throws Exception{ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); double a = Math.sqrt(5.0); double temp1 = (1.0 + a)/2.0; double temp2 = (1.0 - a)/2.0; int r = (int)(1.0/a*(Math.pow(temp1, n) - Math.pow(temp2, n))); System.out.println(r); } }