HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Contests > IMPC - 2013-2014 > problem:


2013-03-30. 50559 - Prime Factors of a Number

IMPC - 2013-2014

Start: Mar.16.2013 at 12:00:00 PM
Finish: Mar.16.2013 at 05:00:00 PM
The contest is finished!
• Contest scoreboard

Guest
• Review clarifications (1)

Contest problems

• 14-05-90. 50549 - k-Nearest Neigh...
• 14-05-95. 50479 - Bit Compressor
• 14-07-10. 50383 - Noisy Mornings
• 14-07-20. 50384 - Permutations revi...
• 14-07-30. 50385 - The 3n + 1 problem
• 14-07-50. 50367 - Bar Codes
• 2013-03-10. 50579 - Pentagonal Nu...
• 2013-03-20. 50589 - The Number of...
• 2013-03-30. 50559 - Prime Fac...
• 2013-03-40. 50685 - Guest Room U...
• 2013-04-10. 50335 - Five Math Ope...
• 2013-04-100. 50323 - Filtering Cont...
• 2013-04-30. 50337 - Exam Averages
• 2013-04-40. 50338 - Convert Into ...
• 2013-04-50. 50774 - Hot Potato
• 2013-04-70. 50296 - Total Discount...
• 2013-04-80. 50343 - The number of...

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 4000/7000/7000/7000 ms. Memory limit 65000/65000/65000/65000 Kb.
Prepared by Ibrahim Mesecan.

kth Prime Factor of a Number

Prime factors of a number are the prime number which divides the number evenly and when you multiply all of them you will have the number itself. For example: 12= 2x2x3. 2, 2 and 3 are the prime factors of 12.

Write a program that is going to show kth prime factor of the given number (m).

Input specification
There is one number n in the first line where 1 ≤ n ≤ 30. Then, in the following n lines, you will be given two numbers m and k where 1 ≤ m ≤ 109 and 1 ≤ k < 15.

Output specification
Show n numbers which represent kth prime factors of the given numbers.
Note: Prime factors are assumend to be in ascending order. If k is larger than the number of prime factors of the given number, show the biggest prime factor. If the number is prime show the number itself.

Sample Input:
  5
  12 3
  7 1
  20 10
  20001 2
  20000001 3

Enter a number..:

Sample Output:
  3
  7
  5
  59
  952381

Output Explanation:

  • Hence, prime factors of 12 are 2, 2, 3, the result is 3
  • 7 is a prime number, the result is 7
  • Prime factors of 20 are 2, 2, and 5. Thus, k is larger than the number of factors. The result is 5
  • etc.


Для отправки решений необходимо выполнить вход.

www.contester.ru