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

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

Hi everyone,

Today's codeforces round involved finding the number of occurrences of a certain AP in a range, for example 1,3,5,7... in a range of 0 to 99.

A lot of users have solved the problem with:

if((n-1)<c) return 0;

 return (n-1-c)/b + 1;

Although such one liners seem simple, basic maths, they are tricky and error prone to come up with during contests, with even some higher rated coders making mistakes in the same. How can I improve this aspect of my maths?

Thanks for your time.

PS: I still don't know why this formula works. Any further problems requiring similar ideas would be appreciated.

Полный текст и комментарии »

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