Блог пользователя Raghu15_47

Автор Raghu15_47, история, 5 лет назад, По-английски

Need help with this number theory problem. Give me some hints, please.

Problem

Given an integer N <= 10^40 find the smallest m <= N such that m/phi(m) is maximum. Where phi is Euler's totient function.

Input:

The first line in the input gives the number of test cases T (T<=200), and then T lines follow each containing an integer N.

Output: Output the smallest required value of m.

Sample Input:

1 10

Output: 6

  • Проголосовать: нравится
  • +8
  • Проголосовать: не нравится

»
5 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +10 Проголосовать: не нравится

phi(m) is m*(1-1/P1)*(1-1/P2)*(1-1/Pn) for m=(P1^A1)*(P2^A2).....(Pn^An), so m/phi(m)=1/((1-1/P1)*(1-1/P2)*(1-1/Pn))=P1*P2...Pn/((P1-1)*(P2-1)*....(Pn-1)) . Which is maximum for minimum value of every Pi and you can see that it is always increasing as X>X-1 so X/(X-1) >1 , Now log2(10^40)=132.87 so you need to find first 133 prime no. And multiply them until the value of there multiplication is less than given N . N=1 is an exception for which the answer is 1 .