蓝桥杯_入门训练_Fibonacci数列
import java.util.*; public class Main { public static void main(String args[]) { int MAX_LEN = 1000005; int arr[] = new int[MAX_LEN]; arr[1] = 1; arr[2] = 1; int mod = 10007; for(int i = 3; i < MAX_LEN; i++) { arr[i] = (arr[i-1] + arr[i-2]) % mod; } Scanner scanner = new Scanner(System.in); int qus = scanner.nextInt(); System.out.println(arr[qus]); } }
本题非常简单,打表即可。
只是本人对蓝桥杯赛制尚且不够熟悉,JAVA语法也有所淡忘,故记下以下几点:
1、int arr[] = new int[Max_len]
2、Scanner scanner = new Scanner(System.in); int a = scanner.nextInt();
3、类必须命名为Main(大写)
4、public static void main(String args[])