Problem 390
Forum rules
As your posts will be visible to the general public you are requested to be thoughtful in not posting anything that might explicitly give away how to solve a particular problem.
This forum is NOT meant to discuss solution methods for a problem.
See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
As your posts will be visible to the general public you are requested to be thoughtful in not posting anything that might explicitly give away how to solve a particular problem.
This forum is NOT meant to discuss solution methods for a problem.
In particular don't post any code fragments or results.
Don't start begging others to give partial answers to problems
Don't ask for hints how to solve a problem
Don't start a new topic for a problem if there already exists one
Don't start begging others to give partial answers to problems
Don't ask for hints how to solve a problem
Don't start a new topic for a problem if there already exists one
See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
-
mdean
- Posts: 206
- Joined: Tue Aug 02, 2011 2:05 am
Problem 390
Probably a stupid question. I'm assuming either b or c are allowed to be zero? And the triangle with (b,c)=(0,2) would be the same as the triangle with (b,c)=(2,0)?

-
aruff
- Posts: 3
- Joined: Sun Jun 24, 2012 7:24 am
Re: Problem 390
I would agree that the problem seems to allow for b or c to be 0 (0 is an integer after all)
This seems inconsistent with the sample result given though.
This doesn't feel like a spoiler to me, but to be safe:
So to summarize I think the problem only uses non-zero b and c, but I do not see anything in the problem's wording to justify this.
This seems inconsistent with the sample result given though.
This doesn't feel like a spoiler to me, but to be safe:
Expand
-
albert
- Posts: 61
- Joined: Sat Aug 02, 2008 12:36 pm
Re: Problem 390
The title of the problem sites "non-rational" sides.So to summarize I think the problem only uses non-zero b and c, but I do not see anything in the problem's wording to justify this.
There are two problems with this:
- it is extremely bad style, if the problem name is part of the problem statement.
- you can't see the title if you're looking at the problem anyway.
In fact I myself went straight to the problem, without seeing its title.
So I definitely think non-rational should be repeated in the body of the problem.
Groetjes Albert
- mpiotte
- Administrator
- Posts: 1961
- Joined: Tue May 08, 2012 5:40 pm
- Location: Montréal, Canada
Re: Problem 390
It is not clear from the problem statement if b or c are allowed to be zero. However, the test value for S(10^6) shows that the correct solution excludes any triangle with b=0 or c=0.
Martin
Martin
Last edited by mpiotte on Fri May 17, 2013 1:04 pm, edited 1 time in total.

- hk
- Administrator
- Posts: 12842
- Joined: Sun Mar 26, 2006 10:34 am
- Location: Haren, Netherlands
Re: Problem 390
It is now.mpiotte wrote:It is not clear from the problem statement if b or c are allowed to be zero. However, the test value for S(10^6) shows that the correct solution excludes any triangle with b=0 or c=0.
Martin

War ruins the life and health of untold numbers of innocent children.
-
jerryhe26
- Posts: 1
- Joined: Mon Jun 25, 2012 9:23 am
Re: Problem 390
Did you mistook sqrt(a^2+b^2) to sqrt(a^2*b^2)??
aruff wrote:I would agree that the problem seems to allow for b or c to be 0 (0 is an integer after all)
This seems inconsistent with the sample result given though.
This doesn't feel like a spoiler to me, but to be safe:So to summarize I think the problem only uses non-zero b and c, but I do not see anything in the problem's wording to justify this.Expand
-
Mr_Nobody
- Posts: 1
- Joined: Wed Jun 27, 2012 6:15 pm
-
Pavgran
- Posts: 1
- Joined: Mon Jul 02, 2012 6:36 pm
- Location: Moscow
Re: Problem 390
Less than a second even with some kind of bruteforce.Mr_Nobody wrote:To those who solved this one, how long did it take to compute for n=10^6?

-
mdean
- Posts: 206
- Joined: Tue Aug 02, 2011 2:05 am
Re: Problem 390
Well, I had a program that did 10^6 correctly in about 2 seconds which ran into problems for 10^10 besides being too slow. I fixed the problem, which brought the running speed up to 8 seconds. Didn't bother trying that with 10^10.Mr_Nobody wrote:To those who solved this one, how long did it take to compute for n=10^6?
Now I have a program that does 10^6 incorrectly in 156 ms...
My latest answer is slightly too high. I must be counting something twice or something...
Update: I found and fixed the overcount. While it still ran quite fast for 10^6, looks like it's going to be another flagrant 1 minute rule violation for 10^10.

-
mdean
- Posts: 206
- Joined: Tue Aug 02, 2011 2:05 am
Re: Problem 390
And now it looks like overflow is going to be a problem. 10^9 runs in about 3 minutes. 10^10 ran overnight and never finished...

-
mdean
- Posts: 206
- Joined: Tue Aug 02, 2011 2:05 am
Re: Problem 390
Well, I think the overflow is fixed, but I seem to be getting an incorrect value for 10^10. Can I pm someone my results for 10^7,10^8, and 10^9?

- Marcus_Andrews
- Administrator
- Posts: 1637
- Joined: Wed Nov 09, 2011 5:23 pm
-
sharyari
- Posts: 2
- Joined: Mon Sep 24, 2012 11:39 am
Re: Problem 390
Hi, I'm not sure if I understand this problem. Is it correct that I am to sum the area of all the triangles with sides (a,b,c) with the given property AND have an even-numbered area?
If that is the correct interpretation, I am kind of stuck and would appreciate it if someone could nudge me in the right direction.
As it is, I am able to find a subset of these triangles rather easily, but a brute-force approach is able to find more such triangles. What am I missing here?
Thank you in advance
If that is the correct interpretation, I am kind of stuck and would appreciate it if someone could nudge me in the right direction.
As it is, I am able to find a subset of these triangles rather easily, but a brute-force approach is able to find more such triangles. What am I missing here?
Thank you in advance
-
thundre
- Posts: 356
- Joined: Sun Mar 27, 2011 10:01 am
Re: Problem 390
There is no mention of a variable a in the problem statement. The sides depend on variables b and c.sharyari wrote:Hi, I'm not sure if I understand this problem. Is it correct that I am to sum the area of all the triangles with sides (a,b,c) with the given property AND have an even-numbered area?
And there is no requirement that the area be an even number, only that it be an integer in the specified range.
It's possible that you understand correctly and have reassigned variables for your own purposes. Yes, the range is too large to do with brute force alone. My successful approach was a hybrid of brute force searching and something else.

-
sharyari
- Posts: 2
- Joined: Mon Sep 24, 2012 11:39 am
Re: Problem 390
Then I believe I have understood it correctly, but obviously too lazy to explain myself well enough.
I believe that I have the "something else" pinned down. Do you think some amount of bruteforce is needed, or is it just the simple way? And if the former, am I right that I should try to figure out which areas of the problem to bruteforce?thundre wrote:My successful approach was a hybrid of brute force searching and something else.
-
thundre
- Posts: 356
- Joined: Sun Mar 27, 2011 10:01 am
Re: Problem 390
My solution took 5 minutes to run -- in Java. It might fit in the 1-minute parameter if converted to C++. So yes, the algorithm I used does require a significant amount of computation to catch all of the triangles.sharyari wrote:I believe that I have the "something else" pinned down. Do you think some amount of bruteforce is needed, or is it just the simple way? And if the former, am I right that I should try to figure out which areas of the problem to bruteforce?
I don't think I can elaborate without spoiling the problem. My best suggestion, which you seem to be doing already, would be to look for triangles which your brute-force search finds but your advanced algorithm does not.

- Marcus_Andrews
- Administrator
- Posts: 1637
- Joined: Wed Nov 09, 2011 5:23 pm
Re: Problem 390
sharyari: I just want to point out that brute force isn't technically required to solve this problem. However, with that being said, it may still be the best approach if your goal is just to get the answer as soon as possible. The answer can be calculated in just a couple milliseconds, but figuring out the algorithm may take more time overall.
