K维数字数组的一个算法的运用,如何利用C程序的编程语言的代码加以实现的呢

Problem Description
What a nice day! The sky is blue, and the sea is calm. It is a day that is suitable for marine navigation training. A training ship of a Naval Training School sails out from the naval port and arrives at a sea area. The navigation instructor is not only an expert in navigation but also an amateur mathematician. The instructor gives the practice assignment as soon as the first student stands at the position of the navigator: First, navigates 1 nautical mile to the east, and then 2 nautical miles to the south, finally 4 nautical miles to the west, and stops at a certain place. The first student accomplishes the task successfully. Then the second student takes the place, and the instructor gives him a new practice assignment: Firstly, navigates 1 nautical mile to the east, then 2 nautical miles to the south, and then 3 nautical miles to the west, finally 3 nautical miles to the north, and stops at a fixed place. Just like this, the students drive the training ship to accomplish the assignment one by one. There is a student who is interested in numbers and taking records. He writes down the first sequence 1, 2, and 4 as soon as the first student accepts the assignment. Later, he writes down the second sequence1, 2, 3, and 6 when the second student accepts the assignment. As a mathematic lover, the student always connects the numbers to some mathematic problems. When he writes down the first sequence, 1, 2, and 4, he figures out that every number in the sequence is the divisors of 4, and 4 is also the last number in the sequence. When he writes down the second sequence1, 2, 3 and 6, he also figures out that every number in the sequence is the divisors of 6, and 6 is also the last number in the sequence. After all the students have finished the assignment, the student looks at the record and comes to the conclusion followed: There is one thing in common for the assignments that the instructor has given to the students, that is, take the direction turning point as the gap, and the sailing distance in all directions form a sequence, every number in the sequence is the divisor of the last one.

The marine navigation training finishes. On the way back, the students have a good time, singing, talking, laughing, and appreciating the sea scenery. The student shows the instructor the records and tells him his findings. The instructor laughs and says to the student, “Well done! You like taking records and thinking, and then finding out something from it. It is a good habit, and also a scientific habit.” The instructor then continues, “Just like science does not have limit, the scientific questions do not have limit, either. The question we have just discussed will not end, and we can also pose new questions.”

The following is the new question the instructor raises:

First, we give a new definition: For a positive integer, if it has K different divisors, then it is called a K- dimension number.
For instance, the positive integer 4 has three divisors, 1, 2and 4, so 4 is a 3- dimension number. The positive integer 6 has four divisors, 1, 2, 3and 6, so 6 is a 4- dimension number.
Now a question is posed: how to work out the nth K-dimension number? (n<10000,Kmax<=100,here Kmax is the greatest prime divisor of K).And you can assume if K is a k-dimension number, it doesn't exceed 3-dimension.

For example, if it is required to work out the second 3-dimension number, that is to say when n=2, K=3, then the answer is 9. Because 4 is the first 3-dimension number, and 9 has three common divisors 1, 3 and 9. Therefore, 9 is the second 3-dimension number.

The student thinks: if n and K are small enough, we can work out easily. Otherwise, we have to turn to the computer for n and K are too big to deal with.

He begins to think it over on the ship.

Input
There are several test cases. Each case takes up a line, contains two positive integers; they are n and K respectively. Input is terminated by the end of the file.

Output
Output the nth K-dimension number, each result takes up one line.

Sample Input
1 3
1 4

Sample Output
4
6

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问

相似问题

4
C++语言编程 运用贪心算法的方法
1
java附加条件的组合数算法
1
一个数列数组的求和再求比率的问题,如何利用C语言的方法编程算法解决
0
数组在图上的移动的一个算法的问题,要综合运用C语言知识的程序的编写
0
序列三元组的计算的算法问题运用的C语言的编程技术如何结局
1
算出给定数各个位上数字为偶数的和的算法问题,采用C语言编程的知识解答
0
如何解决这里的数塔覆盖的一个算法问题,运用的是C编程语言的方法的实现
0
筷子的排序问题,采用组合算法的实现,如何利用C语言编程
0
行列式绝对值数字序列的问题求值,运用C语言算法编程的技术
0
字母字面值和数字的组合排序算法问题,采用C语言编程思路的实现方式
0
矩阵数字的一个路径的算法,怎么利用C语言编写程序的方式实现的
1
三角形各个边长的组合的判断的算法问题,如何运用C程序设计技术来实现
0
多行对偶匹配数组的一个算法问题,运用C语言编程的技术的实现的做法
1
输出数组所有比一个数更大的数字,采用C 语言的算法去编程怎么来做
0
丢石头的游戏的一个算法的问题如何采用C语言的程序的编程的方法来实现的呢
0
欧拉的数字问题的算法怎么利用C语言的程序的编写设计的思想来实现代码的
0
用C语言的编程的思想的方式来设计程序解决这里的麻将数组的算法的问题怎么做
0
判断四个点能否组成正方形的一个算法的问题,如何利用C语言程序的设计的方式来做
0
数字连乘的一个算法问题,循环的计算用C语言的程序设计的办法
1
输入的数字按要求求和的算法,利用C语言的程序设计的语言的解决做法