A simple number theory problem

Правка en4, от radoslav11, 2017-02-07 15:21:06

Hello everyone!

Today I was solving a problem and I reduced it to finding a maximum of a function. So in short what I need is the following:

, where M, a, b ≤ 109.

It's obvious that iff , but I cannot find an easy way to get the maximum if . I will appreciate any help on the problem.

PS: a, b and M are given as queries so I need an algorithm to answer up to 105 queries.

UPDATE: It's actually pretty simple. actually has values of form . Then it's obvious that the solution will be .

Теги number theory, problem

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en4 Английский radoslav11 2017-02-07 15:21:06 4
en3 Английский radoslav11 2017-02-07 15:20:16 2 Tiny change: 'hat $\max f(x) = M - ' -> 'hat $\max g(x) = M - '
en2 Английский radoslav11 2017-02-07 13:45:12 206
en1 Английский radoslav11 2017-02-07 12:57:42 528 Initial revision (published)