Problem 338

A place to air possible concerns or difficulties in understanding ProjectEuler problems. This forum is not meant to publish solutions. This forum is NOT meant to discuss solution methods or giving hints how a problem can be solved.
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.

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


See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
Post Reply
danielwallace
Posts: 1
Joined: Sun May 15, 2011 6:21 pm

Problem 338

Post by danielwallace »

I am confused about which rectangles to count...
for the example 9x4 i understand there are three.
but for the 9x8 example I also see three.
I see the 18x4 and the 12x6, but i also see a 6x12
by cutting it like the 3rd rectangle in the first example
but by going 4 down instead of 2.

Should i count the 12x6 and the 6x12 as just one rectangle?
User avatar
Lord_Farin
Posts: 239
Joined: Wed Jul 01, 2009 10:43 am
Location: Netherlands

Re: Problem 338

Post by Lord_Farin »

Problem 338 (View Problem)
Problem statement wrote: ...
Note that rectangles congruent to the initial one are not counted in F(w,h).
Note also that rectangles with dimensions w × h and dimensions h × w are not considered distinct.
...
Therefore, the answer to your question is yes. I hope this has clarified the problem for you.
Image
sivakd
Posts: 217
Joined: Fri Jul 17, 2009 9:37 am
Location: California, USA
Contact:

Re: Problem 338

Post by sivakd »

I get correct answer for G(10^5) but my final answer is still wrong. Not sure if it's due to integer overflow. Or are there special cases for higher values of N?

Edit: Never mind, it was just an overflow issue.
Image
puzzle is a euphemism for lack of clarity
Hibernatus34
Posts: 31
Joined: Mon May 16, 2011 7:03 am

Re: Problem 338

Post by Hibernatus34 »

Hello,

I'm sorry if this is a silly question, but is this problem really solvable in less than a minute on a modest computer ?
I have a correct algorithm which worked for the 3 given examples. Seemed optimized to me (i'm not talking about low level optimization of course), but it's way too long for 10^12.

Thanks.
Image Joined PE in May 2011
User avatar
hk
Administrator
Posts: 12842
Joined: Sun Mar 26, 2006 10:34 am
Location: Haren, Netherlands

Re: Problem 338

Post by hk »

Yes, it can be solved in about 10 to 20 seconds.
Image
War ruins the life and health of untold numbers of innocent children.
Hibernatus34
Posts: 31
Joined: Mon May 16, 2011 7:03 am

Re: Problem 338

Post by Hibernatus34 »

Thanks a lot.
Only 10-20 seconds sounds impressive.
But i got a new idea i will try soon, so there's hope :)
Image Joined PE in May 2011
spanklord
Posts: 1
Joined: Thu Jun 23, 2011 4:11 pm

Re: Problem 338

Post by spanklord »

Yes, it can be solved in about 10 to 20 seconds.
Been stuck on this problem now for quite some time.
I have the same problem as Hibernatus34 and i was just wondering if you actually use the functions F as it is specified or is there a more... compact way ?
thundre
Posts: 356
Joined: Sun Mar 27, 2011 10:01 am

Re: Problem 338

Post by thundre »

spanklord wrote:
Yes, it can be solved in about 10 to 20 seconds.
Been stuck on this problem now for quite some time.
I have the same problem as Hibernatus34 and i was just wondering if you actually use the functions F as it is specified or is there a more... compact way ?
If you implement G by summing F for all h <= w <= 1e12, that's about 5e24 add operations. No, I don't think he's doing that in 20 seconds. There must be a simpler way to calculate G.
Image
Hibernatus34
Posts: 31
Joined: Mon May 16, 2011 7:03 am

Re: Problem 338

Post by Hibernatus34 »

Before i waste a whole day on this problem i have a question : does it require some math knowledge ?

Today i've started to study it again.
So far i've only rewritten the same code as my first attempt (had lost it), which calculates G(10^5) in 23 s (brute force obviously).
I'm not asking for a hint, just trying to know if i simply have a chance to solve this problem.
Last edited by Hibernatus34 on Sun Jul 17, 2011 6:27 pm, edited 1 time in total.
Image Joined PE in May 2011
User avatar
Francky
Posts: 90
Joined: Sat May 07, 2011 3:49 pm
Location: South of France

Re: Problem 338

Post by Francky »

I got G(10⁵) in 40ms and G(10⁹) in 3min (and I'm proud of this) ; brute force, even optimized, isn't able to catch G(10¹²).
It would take a week or more !!!
I can't optimize more my code, I have to use a totally new method, but wich ?
(PM me a chapter to study, please)
Thanks.
ImageEntia non sunt multiplicanda praeter necessitatem
xiekaixuan
Posts: 1
Joined: Thu Sep 01, 2011 12:59 pm

Re: Problem 338

Post by xiekaixuan »

Hello,

Can this problem 338 be solved by Python with in several minutes?

Thank you.
Post Reply