搜狐畅游笔试题Java工程师

一个公司从一个试用期员工到N个月后,有多少员工
下面是我做的,如果有问题求赐教
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);  }
}

#搜狐##Java工程师#
全部评论
同畅游 问下状态大概多久会更新
点赞 回复 分享
发布于 2017-09-18 09:01
就是个fibonacci类似的数列 十行可以搞定了
点赞 回复 分享
发布于 2017-09-17 17:08
f(n)=f(n-1)+f(n-3)
点赞 回复 分享
发布于 2017-09-17 17:02
发帖格式不好看,下面我沙发再发一次,谢谢指导 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);     } }
点赞 回复 分享
发布于 2017-09-17 16:55

相关推荐

03-21 10:53
复旦大学 Java
大家好,我是@程序员花海,眼下&nbsp;26&nbsp;届春招、27&nbsp;届暑期实习全面开启,后端卷到没边,AI&nbsp;Agent的岗位占主导,很多牛友在我的评论区留言,想让我出一份Agent学习路线。我特意去看了下,打开淘天的招聘页面,以校招为例,一眼望去全是AI相关的岗位,只能说之后绝大多数岗位都会快速推进AI的落地和实践。之前写过&nbsp;Java&nbsp;后端&nbsp;3&nbsp;个月抢救路线https://www.nowcoder.com/discuss/824693499982315520?sourceSSR=users,也收到了牛友们的强烈好评,这次专门给后端转&nbsp;Agent做一套最少必要知识路线——&nbsp;不堆概念、不啃论文,只学面试必问、项目...
在职牛马didi:这篇路线整理得很系统,把后端知识映射到Agent体系这个思路特别实用。我自己也是从Java转做AI的,感触很深:工程底子扎实的人转Agent确实有优势,RAG和工具编排这些核心能力本质上都是后端逻辑的延伸。我们团队在做天猫的AI应用落地,方向跟你这篇路线里的企业级RAG和Agent系统很接近。暑期实习还在招AI应用研发工程师,JD可以参考看看跟你背景是否匹配:https://www.nowcoder.com/jobs/detail/440929?jobId=440929
软件开发投递记录
点赞 评论 收藏
分享
01-30 09:45
燕山大学 Java
喵_coding:这种直接跑就完事了 哪有毕业了才签合同 任何offer和三方都没有的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务