NewYang2020 @ 2020-11-21 20:14:05
import java.math.BigInteger;
import java.util.Scanner;
class Main{
public static void main(String[] args) {
BigInteger b1 = new BigInteger("1");
BigInteger b2 = new BigInteger("1");
BigInteger b3 = new BigInteger("2");
int N;
Scanner in = new Scanner(System.in);
N = in.nextInt();
if(N == 1)
System.out.println(1);
else if (N == 0)
System.out.println(0);
else if(N == 2)
System.out.println(2);
else if(N == 3)
System.out.println(3);
else{
for(int i = 1; i < N; i++){
b3 = b1.add(b2);
b1 = b2;
b2 = b3;
}
System.out.println(b3);
}
}
}
注意N=0时的情况
by CGDGAD @ 2020-11-21 20:15:04
@NewYang2020 赶快自删,否则一大堆sqlm将来袭
by CGDGAD @ 2020-11-21 20:15:16
sqlm,讨论区题解
by Foofish @ 2020-11-21 20:15:18
sqlm
by Real_Create @ 2020-11-21 20:23:13
sqlm
by xkcdjerry @ 2020-11-21 20:26:43
sqlm tlqtj https://www.luogu.com.cn/discuss/show/241461
by SamariumPhosphide @ 2020-11-21 21:06:59
太强了,thx
by OutsideR_ @ 2021-01-03 19:49:43
python党狂喜