How to get better at "BASIC" Math? (Ft. Round 986 B)

Revision en1, by cbdb, 2024-11-11 00:38:20

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 1 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.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English cbdb 2024-11-11 00:39:56 2 Tiny change: ' range of 1 to 99.\n\' -> ' range of 0 to 99.\n\'
en1 English cbdb 2024-11-11 00:38:20 688 Initial revision (published)