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

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

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 .

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

»
8 лет назад, # |
  Проголосовать: нравится +45 Проголосовать: не нравится

Have you thought about the case where a = 0? What values can you get for f then? What's the max then? Is it much harder when a ≠ 0?