10483  The Sum Equals the Product
Moderator: Board moderators

 Guru
 Posts: 834
 Joined: Wed May 29, 2002 4:11 pm
 Location: Wroclaw, Poland
 Contact:
10483  The Sum Equals the Product
This problem has 354 such sums / products in range 0.00 ... 256.00 or I'm wrong ? Maybe I miss something ?
DM
DM
If you really want to get Accepted, try to think about possible, and after that  about impossible ... and you'll get, what you want ....
Born from ashes  restarting counter of problems (800+ solved problems)
Born from ashes  restarting counter of problems (800+ solved problems)

 Learning poster
 Posts: 67
 Joined: Sun Sep 22, 2002 5:40 am
 Location: Taiwan

 Problemsetter
 Posts: 22
 Joined: Tue Jun 11, 2002 12:35 am

 Guru
 Posts: 834
 Joined: Wed May 29, 2002 4:11 pm
 Location: Wroclaw, Poland
 Contact:
I got the same problem like windows2k ....
I think, that I sort it correctly, but got WA, I don't know why
DM
I think, that I sort it correctly, but got WA, I don't know why
DM
If you really want to get Accepted, try to think about possible, and after that  about impossible ... and you'll get, what you want ....
Born from ashes  restarting counter of problems (800+ solved problems)
Born from ashes  restarting counter of problems (800+ solved problems)

 Guru
 Posts: 834
 Joined: Wed May 29, 2002 4:11 pm
 Location: Wroclaw, Poland
 Contact:
I got Accepted. I have one incorrect line in my output )
But I have a question to all. I write bruteforce solution, which computes solution for this problem and this program runs for 12 seconds. Is there any fast math solution for this ? Solution, which pass time limit (10 sec) in this site ? I don't have post this code here ... Maybe I miss some pruning condition ?
I use integers instead of doubles, and use only two variables to compute results (i.e. "a" and "b"). Could anyone tell me, if such solution exist ?
Best regards
DM
But I have a question to all. I write bruteforce solution, which computes solution for this problem and this program runs for 12 seconds. Is there any fast math solution for this ? Solution, which pass time limit (10 sec) in this site ? I don't have post this code here ... Maybe I miss some pruning condition ?
I use integers instead of doubles, and use only two variables to compute results (i.e. "a" and "b"). Could anyone tell me, if such solution exist ?
Best regards
DM
If you really want to get Accepted, try to think about possible, and after that  about impossible ... and you'll get, what you want ....
Born from ashes  restarting counter of problems (800+ solved problems)
Born from ashes  restarting counter of problems (800+ solved problems)

 Guru
 Posts: 1080
 Joined: Thu Dec 19, 2002 7:37 pm
Dominic: I do bruteforcing within the code and finish under 0.05 sec, most of it spent on my lousy sorting algo (O(n^2)).
I think you yourself give the answer: you only have to iterate a and b; c can be calculated from them (a+b+c=a*b*c so c=(a+b)/(a*b1)). I guess it's all about boundary conditions for a and b. If you set a<=b<=c, then a is bounded by a*a*a<256.00 and b is bounded by a*b*b<256.00. Should be enough to finish in a split second. And: once you know the upper bound for a from your previous brute force, you can even speed up more...
I hope I don't give away too much
If so, tell me and I'll remove this post.
I think you yourself give the answer: you only have to iterate a and b; c can be calculated from them (a+b+c=a*b*c so c=(a+b)/(a*b1)). I guess it's all about boundary conditions for a and b. If you set a<=b<=c, then a is bounded by a*a*a<256.00 and b is bounded by a*b*b<256.00. Should be enough to finish in a split second. And: once you know the upper bound for a from your previous brute force, you can even speed up more...
I hope I don't give away too much
If so, tell me and I'll remove this post.

 Guru
 Posts: 834
 Joined: Wed May 29, 2002 4:11 pm
 Location: Wroclaw, Poland
 Contact:
You have right little joey )
I use incorrect boundary values for this problem )
DM
PS. You can remove your post now ))
I use incorrect boundary values for this problem )
DM
PS. You can remove your post now ))
If you really want to get Accepted, try to think about possible, and after that  about impossible ... and you'll get, what you want ....
Born from ashes  restarting counter of problems (800+ solved problems)
Born from ashes  restarting counter of problems (800+ solved problems)

 Guru
 Posts: 834
 Joined: Wed May 29, 2002 4:11 pm
 Location: Wroclaw, Poland
 Contact:

 New poster
 Posts: 44
 Joined: Tue Apr 15, 2003 4:31 pm
 Location: Chittagong,Bangladesh
 Contact:
still wrong answer
I found 354 with 0 = 0 + 0 + 0 = 0 * 0 * 0;
But still wrong answer.Is there anything else?
Or above is invalid?
All types of sort in my code i think correct.But what happen i don't know.Can anyone help me?[/b]
But still wrong answer.Is there anything else?
Or above is invalid?
All types of sort in my code i think correct.But what happen i don't know.Can anyone help me?[/b]

 Guru
 Posts: 834
 Joined: Wed May 29, 2002 4:11 pm
 Location: Wroclaw, Poland
 Contact:
0 = 0 + 0 + 0 = 0 * 0 * 0 is invalid
There are 354 lines without this line.
Maybe you have another mistake in your code
DM
There are 354 lines without this line.
Maybe you have another mistake in your code
DM
If you really want to get Accepted, try to think about possible, and after that  about impossible ... and you'll get, what you want ....
Born from ashes  restarting counter of problems (800+ solved problems)
Born from ashes  restarting counter of problems (800+ solved problems)

 New poster
 Posts: 44
 Joined: Tue Apr 15, 2003 4:31 pm
 Location: Chittagong,Bangladesh
 Contact:
Ohho
Dominik Michniewski pls help me by following result:
1.First output.
2.Last output.
3.How many multiple solution for one sum:
My first output is 5.25=.............=.........
Last one is 254.52=............=............(it is for multiple )
is little joey solve it in a and b as double or long What?
Dominik Michniewski pls help me by following result:
1.First output.
2.Last output.
3.How many multiple solution for one sum:
My first output is 5.25=.............=.........
Last one is 254.52=............=............(it is for multiple )
is little joey solve it in a and b as double or long What?

 Guru
 Posts: 1080
 Joined: Thu Dec 19, 2002 7:37 pm
I use pascal longint (32 bit signed) to store a, b and c in cents, so the actual equation is: c:=(10000*(a+b)) div (a*b10000). The first output is (no. 1) 5.25 = x.xx + x.xx + x.xx = x.xx * x.xx * x.xx, and the last two (no. 353 and no. 354) are 254.52 = x.xx + x.xx + xxx.xx = x.xx * x.xx * xxx.xx and 254.52 = x.xx + x.xx + xxx.xx = x.xx * x.xx * xxx.xx.
Hope it helps...
Hope it helps...