思路分析:该题需注意使用大数,在java中大数函数gcd求取最大公约数
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n1=2020;
int n2=520;
BigInteger f1[]=new BigInteger[n1];
f1[0]=f1[1]=BigInteger.ONE;
BigInteger f2[]=new BigInteger[n2];
f2[0]=f2[1]=BigInteger.ONE;
for(int i=2;i<2020;i++){
f1[i]=f1[i-1].add(f1[i-2]);
}
for(int i=2;i<520;i++){
f2[i]=f2[i-1].add(f2[i-2]);
}
System.out.println(f1[2019].gcd(f2[519]));
}
}