微软笔试第二批
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
如输入9:
1.替换为9的最大质约数3;
2.减一变成2;
3.减一变成1;
4.减一变成0
所以答案是,最少需要4次操作。