发帖格式不好看,下面我沙发再发一次,谢谢指导 import java.util.Scanner; import java.math.BigInteger; import java.util.LinkedList; import java.util.Queue; public class Main {     public static void main(String[] args) {         Scanner in = new Scanner(System.in);         int n = in.nextInt();         System.out.println(solve(n));         in.close();     }     public static BigInteger solve(int n) {         BigInteger m1 = BigInteger.valueOf(0);         BigInteger m = BigInteger.valueOf(0);         BigInteger yes = BigInteger.valueOf(1);         Queue<BigInteger> queue = new LinkedList<BigInteger>();         if (n <= 3) {             return BigInteger.valueOf(1);         }         while (queue.size() < 3) {             queue.offer(m1);         }         while (n - 3 > 0) {             --n;             yes = yes.add(queue.poll());             queue.offer(yes);         }         while (!queue.isEmpty()) {             m = m.add(queue.poll());         }         return m.add(yes);     } }
点赞 1

相关推荐

不愿透露姓名的神秘牛友
07-15 17:46
暑期就挂了,秋招还有机会吗
大聪明777:研发提前批,14号刚开的,官网上面的配图上有写。提前批没过的话,秋招还可以投,不过前面的笔试/面试记录会被保留,供秋招参考
26届校招投递进展
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-16 12:23
点赞 评论 收藏
分享
写不来代码的小黑:这么小的城市能有做it的公司也不容易
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务