微软笔试第二批

100, 100, 90(超时)
第一题:

A company has hired N interns, labeled from 1 to N. Each intern is given a device which generates a number everyday that will be used as a password for their authentication at the office door every day in the morning. The internship is for 50 days numbered from 0 to 49. Initially(on the 1st day), the number in the device of the kth intern will be equal to (5000*k)
From the second day(i=1), a new number will be generated every day in each device in the following way:
Day(i) = day(i-1)+5000+I
Find the label of an intern from the given password used by him/her.

Input1: N, number of interns
Input2: P, password used

Output: return the label of the intern to whom the given password belongs to.

Examples:
Input1: 1
Input2: 5000
Output:1
Explanation: 5000 is the number of the first intern on day0

第二题:给出二叉树的中序遍历和前序遍历,要求按某种次序遍历输出。某种次序是:层序从底向上,下层节点的值在前面。
第三题:有一个数,每次选择一种操作,可以减一,也可以变为其最大的质约数(不能是这个数本身,也不能是1),直到变为0,求最少的操作次数。
如输入9:
1.替换为9的最大质约数3;
2.减一变成2;
3.减一变成1;
4.减一变成0
所以答案是,最少需要4次操作。

答案:
#微软##笔试题目##题解#
全部评论
100, 100, 0 第三题没时间了,提前交卷😂
点赞 回复 分享
发布于 2019-09-27 23:31
大佬估计一下这一次a多少才能进面试啊😂
点赞 回复 分享
发布于 2019-09-27 23:35
大佬强,先马再看。怎么感觉没什么人做的样子
点赞 回复 分享
发布于 2019-09-28 00:59

相关推荐

评论
1
28
分享

创作者周榜

更多
牛客网
牛客企业服务