Пожалуйста, подпишитесь на официальный канал Codeforces в Telegram по ссылке https://t.me/codeforces_official. ×

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

Автор Pathetic_loser, 9 лет назад, По-английски

Problem

Some help/hint would be greatly appreciated :)

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

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

There are at most 11 prime numbers less than sqrt(N). Try all possible assignments of these switches (211 ways). Each lamp is now attached to at most 1 unassigned switch (those are greater than sqrt(N)) and we can solve it by greedy approach (count the number of on/off lamps for each switch).