Given a positive integer k and two non-negative integers n and m such that we need to take out a certain non-negative integer from n and certain non-negative integers from m such that the sum of these two is <=k.
Formally, n, m>=0, and k>0. Number of ways to take a and b from n and m such that
0<=a+b<=k
The number of such (a,b) pairs?
I can do it in a linear solution. Any O(1) combinatorics solution? Please let me know. I need this solve https://mirror.codeforces.com/problemset/problem/1744/F -> I got an idea where in i want to optimize from O(n*n) to O(n).
The below solution worked and i got AC: Submission Using this formula: https://mirror.codeforces.com/contest/1744/submission/179129170