I'm intrested in how to learn to do all those math problems, since I didn't really follow math in most of middle school and most of the high school, I lack a lot of concepts plus education was pretty bad, with most proffesors not explaining well. I find myself discouraged whenever such problems arise, so I would like to know is it me, or I should learn some concepts. IF so what?

colin galen's youtube channel

wich videos specifically

search colin galen number theory on youtube

got it

thx

In math/math related problems you mostly encounter algebraic, rarely geometric concepts. First of all, you have to be familiar with number theory, know how numbers operate, be used in functions, how they get canceled in some cases. It's advised to know some basic formulas as $$$(a+b)^2=a^2+2ab+b^2$$$. And it's easier if you divide a task into subtasks.

Example problem: You are given an array $$$a$$$ of $$$n$$$ integers. You have to find some integer $$$m$$$, so that $$$f(m)$$$ is maximised, where $$$f(m)=(m\ mod\ a_1)\ +\ (m\ mod\ a_2)\ +\ ...\ +\ (m\ mod\ a_n)$$$

You start out simple, what is the maximum value of $$$m\ mod\ a_i$$$? It's $$$a_i-1$$$, when you set $$$m$$$ to some $$$a_i \times k - 1$$$, where $$$k$$$ is an integer

Furthermore, can you choose such $$$m$$$, that $$$m\ mod\ a_i$$$ is maximised for all $$$i$$$? Turns out yes! If you multiple all elements of the array and subtract one, so $$$m=a_1 \times a_2 \times ... \times a_n-1$$$ (However there is a simpler solution, where $$$m=-1$$$), and for every $$$i$$$, $$$m\ mod\ a_i$$$ is maximised

Lastly, when you fully done and understood the problem, you can cancel out unnecessary things, and the remaining part is to implement. In this problems case, the final answer is $$$sum(a)-len(a)$$$

Of course all problemsetters tend to hide the answer in testcases, where they give weird examples, so it's almost impossible to find any pattern fast. So, it's easier to check cases by hand and hopefully be able to recognise a consistent rule, pattern, working for all cases.

If you struggle with basic math concepts, then you could look for courses in any online resource, after all, internet is a free-source library, where you can find almost anything. Don't know/understand something? Google it!

I hope this one was helpful

it felt good to read , sir !

Thanks! I appreciate that :)

Thank you so much for taking your time to answer this. I really like your problem and explanation of it.

If you're lacking mathematical maturity then I'd say picking a discrete maths book and working through it will be beneficial in the long term. If you have to you should review your school math textbooks and re-learn it (no shortcuts here if you're lacking those foundations).

I think math in CP is basically practical and common sense math which you get to learn by solving random problems