i think it is a Combinatorics problem, what we want to solve is there are how many a,b,c such that a+b+c=n and a<b<c.
but it is out of my ability.

Moderator: Board moderators
Are you saying there is a recurrence relation? Could you please explain that?f74956227 wrote:you can find the formular f[n] = f[n-1] ... (just think yourself)
emotional blind wrote:wahaha,
There is O(1) solution. If it is hard for you, then you can try O(n) solution.
Just iterate over number of red balls, for k red balls, try to find out kmax, and kmin,
here kmax = maximum number of blue ball you can have when number of red ball is k
and kmin = minimum number of blue ball you can have when number of red ball is k
then just add kmax-kmin, for every k.
Hope this idea will help you.
thanks.
i dont think ur method could work.I just wrote and saw the output is simply different when n=100,,I didnt check for other values.i think the answer for n is round((n-3)^2/12)
if it's spoiler tell me to delete it?
I looked deeply and finally got the O(1) solution. its easy.if u look over the sample input and output u can urself find it.i want to know the O(1) solution.
wahaha wrote:can somebody tell me how to solve this problem?
i think it is a Combinatorics problem, what we want to solve is there are how many a,b,c such that a+b+c=n and a<b<c.
but it is out of my ability.
Code: Select all
Case 1: 83334500004
Well...that actually works...@kbr_iut if your output is different when n = 100, then you must be mistaken and not him.by kbr_iut » Thu Aug 14, 2008 10:15 am
i dont think ur method could work.I just wrote and saw the output is simply different when n=100,,I didnt check for other values.hamedv wrote
i think the answer for n is round((n-3)^2/12)
if it's spoiler tell me to delete it?