Problem 127

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.
elr
Posts: 67
Joined: Thu Apr 09, 2009 9:47 am

problem 127

Post by elr »

i wrote a program that successfuly compute sigma(c) for c < 1000
however i keep getting wrong answer for c < 110000 ...,here some abc triple's my program found :

(20077,89898,109975)
(24833,85145,109978)
(23367,86612,109979)
(45635,64346,109981)
(4446,105535,109981)
(21145,88838,109983)
(23133,86852,109985)
(17665,92321,109986)
(42737,67250,109987)
(19665,90323,109988)
(32197,77793,109990)
(39168,70823,109991)
(17879,92113,109992)
(50402,59591,109993)
(33233,76761,109994)
(41296,68699,109995)
(9628,100367,109995)
(27471,82525,109996)
(29263,80735,109998)
(42555,67444,109999)

i keep getting that the answer is 2573264393 however the site doesn't accept it

can someone verify sigma(c) for c < 10000
so i can see if i got a problem with c's that are higher than 1000
Image
User avatar
Georg
Posts: 157
Joined: Mon Jan 21, 2008 7:00 am
Location: Mannheim, Germany
Contact:

Re: problem 127

Post by Georg »

Review your check for "rad(abc) < c".
elr
Posts: 67
Joined: Thu Apr 09, 2009 9:47 am

Re: problem 127

Post by elr »

thanks alot,i manage to fix & solve the problem :D
Image
shadowx360
Posts: 4
Joined: Mon May 25, 2009 6:21 pm

Problem 127

Post by shadowx360 »

My code for problem 127 is way too slow, it gets caught on numbers like 2048 and stays there for hours at a time. I have tried to speed it up significantly using the 6k+-1 prime test and skipping when both c and a are even.

Below is problem 127 from the site:
The radical of n, rad(n), is the product of distinct prime factors of n. For example, 504 = 2^(3) × 3^(2) × 7, so rad(504) = 2 × 3 × 7 = 42.

We shall define the triplet of positive integers (a, b, c) to be an abc-hit if:

1. GCD(a, b) = GCD(a, c) = GCD(b, c) = 1
2. a < b
3. a + b = c
4. rad(abc) < c

For example, (5, 27, 32) is an abc-hit, because:

1. GCD(5, 27) = GCD(5, 32) = GCD(27, 32) = 1
2. 5 < 27
3. 5 + 27 = 32
4. rad(4320) = 30 < 32

It turns out that abc-hits are quite rare and there are only thirty-one abc-hits for c < 1000, with ∑c = 12523.

Find ∑c for c < 120000.

Note: This problem has been changed recently, please check that you are using the right parameters.

Here is my C++ code:

Code: Select all

### deleted by ed_r ###
I have no idea why it would get stuck on numbers like 2048, and even when it is not getting stuck, calculating the sum takes much longer than one minute with this code. Can anyone give me any pointers to making this code more efficient?
User avatar
ed_r
Posts: 1009
Joined: Sun Jul 29, 2007 10:57 am

Re: Problem 127

Post by ed_r »

Please don't post solution code.

If your code is slow, but still works, then there's no need to ask here: use the solvers' forum for problem 127.
!647 = &8FDF4C
shadowx360
Posts: 4
Joined: Mon May 25, 2009 6:21 pm

Re: Problem 127

Post by shadowx360 »

Where is the solver's forum? I haven't been able to solve this yet, my code works, but you would have to wait about 2 weeks to get the answer (optimistically speaking). I can't enter the thread for 127 on projecteuler, since I haven't been able to obtain my answer. I believe there might have been a glitch in the code that causes it to freeze on certain numbers.
User avatar
daniel.is.fischer
Posts: 2400
Joined: Sun Sep 02, 2007 11:15 pm
Location: Bremen, Germany

Re: Problem 127

Post by daniel.is.fischer »

Then you can PM me your code. If I find a glitch, I might give you a useful hint.
Il faut respecter la montagne -- c'est pourquoi les gypa&egrave;tes sont l&agrave;.
shadowx360
Posts: 4
Joined: Mon May 25, 2009 6:21 pm

Re: Problem 127

Post by shadowx360 »

Thanks, I found that rad(abc) is the same as rad(a)*rad(b)*rad(c) when they are coprime. This speed it up enough for me to get a solution. Thanks for your time and offer.
zwuupeape
Posts: 189
Joined: Tue Jun 09, 2009 6:11 pm

Problem 127

Post by zwuupeape »

I'm not sure if that would spoil it. I have a question about this problem, probably anyone who solved it will understand what I'm talking about. Does the special case count ?
User avatar
daniel.is.fischer
Posts: 2400
Joined: Sun Sep 02, 2007 11:15 pm
Location: Bremen, Germany

Re: Problem 127

Post by daniel.is.fischer »

I solved it, but I don't understand. Except, possibly you interpret positive as nonnegative. If that's the case, no, positive means > 0, not [ge] 0. Otherwise, I don't see a possibility for a special case.
Il faut respecter la montagne -- c'est pourquoi les gypa&egrave;tes sont l&agrave;.
zwuupeape
Posts: 189
Joined: Tue Jun 09, 2009 6:11 pm

Re: Problem 127

Post by zwuupeape »

gcd(9,1) = gcd(8,1) = gcd(9,8) = 1

1 + 8 = 9

rad(1*8*9) = 1*2*3 = 6 < 9
User avatar
daniel.is.fischer
Posts: 2400
Joined: Sun Sep 02, 2007 11:15 pm
Location: Bremen, Germany

Re: Problem 127

Post by daniel.is.fischer »

Yes, but it's not special.
gcd(1,48) = gcd(1,49) = gcd(48,49) = 1
1 < 48
1 + 48 = 49
rad(1*48*49) = rad(24*3*72) = 2*3*7 = 42 < 49.
Il faut respecter la montagne -- c'est pourquoi les gypa&egrave;tes sont l&agrave;.
zwuupeape
Posts: 189
Joined: Tue Jun 09, 2009 6:11 pm

Re: Problem 127

Post by zwuupeape »

I meant the general case when a = 1.

Damn, this problem is hard ...
User avatar
hk
Administrator
Posts: 12832
Joined: Sun Mar 26, 2006 10:34 am
Location: Haren, Netherlands

Re: Problem 127

Post by hk »

Less hard than 257 I think, so keep trying.
Image
War ruins the life and health of untold numbers of innocent children.
zwuupeape
Posts: 189
Joined: Tue Jun 09, 2009 6:11 pm

Re: Problem 127

Post by zwuupeape »

I solved it, but I still think it's hard. The limit just allows more naive solutions.

Problem 257 is not so hard, in my opinion. It's not hard to understand what you should search for, and not very hard to find it once you do. There are many problems here solved by > 1000 people that I found more difficult. It's really weird that so few people have solved it by now ..
User avatar
daniel.is.fischer
Posts: 2400
Joined: Sun Sep 02, 2007 11:15 pm
Location: Bremen, Germany

Re: Problem 127

Post by daniel.is.fischer »

zwuupeape wrote:I solved it, but I still think it's hard. The limit just allows more naive solutions.

Problem 257 is not so hard, in my opinion. It's not hard to understand what you should search for, and not very hard to find it once you do. There are many problems here solved by > 1000 people that I found more difficult. It's really weird that so few people have solved it by now ..
Just shows that hardness is a very individual matter. We didn't expect 257 to have so few solutions either.
Il faut respecter la montagne -- c'est pourquoi les gypa&egrave;tes sont l&agrave;.
zwuupeape
Posts: 189
Joined: Tue Jun 09, 2009 6:11 pm

Re: Problem 127

Post by zwuupeape »

I hope that means you're saving another really hard one for next time :)
User avatar
daniel.is.fischer
Posts: 2400
Joined: Sun Sep 02, 2007 11:15 pm
Location: Bremen, Germany

Re: Problem 127

Post by daniel.is.fischer »

We have one or two in the making that might turn out very hard indeed. We just don't know yet which that will actually be 8-)
Il faut respecter la montagne -- c'est pourquoi les gypa&egrave;tes sont l&agrave;.
Smaug
Posts: 15
Joined: Thu Aug 06, 2009 5:08 pm

Re: problem 127

Post by Smaug »

Would it be possible to add to the problem description:
Find sum(c) for not necessarily distinct c <= 120000.
That confused me a lot.
User avatar
Jochen_P
Posts: 55
Joined: Mon Oct 05, 2009 10:47 am
Location: Stuttgart, Germany

Re: problem 127

Post by Jochen_P »

Got it down to 5 minutes in python, trying hard not to try my solution as I violated the 1 minute rule a bit too often recently :roll:

It was sooo frustrating when I revisited the code once in a while for the past few months, not being able to get a result in below some days of runtime, when suddenly ... It fell like scales from my eyes :mrgreen:

edit: posted my solution with a runtime of 20 secs ... Gawd. It took only half a year to solve this one (details for further amusement in problem forum)
Image
Post Reply