Problem 439

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
Maybeso83
Posts: 2
Joined: Fri Mar 15, 2013 7:34 pm

Problem 439

Post by Maybeso83 »

Problem 439 (View Problem)
I've been working on S(N) for N < 100, and occasionally trying the test case 103 and larger N. The times were getting bad too fast so I wrote a skeleton program

Code: Select all

nMax = 10^11
nMod = 10^9
// Prog1
f = 1234
for n = 1 to nMax
  c = n*f mod nMod

// Prog2
for n = 1 to nMax
  for f = 1 to n
    c = n*f mod nMod
and got these timings

Code: Select all

nMax 	 Prog1   	  Prog2
10^3 	  0.001 s 	   0.497 s
10^4 	  0.009 s 	  48.622 s
10^5 	  0.110 s 	5534.003 s
10^6 	  1.119 s
10^7 	 11.015 s
10^8 	110.096 s

My current not-too-brilliant version:
10^3 	 563576517282 	 60.325 s
The solution is probably less complex than prog2, but can it really beat prog1?
I'm thinking there's a problem with my machine or my machine+language is not sufficient to solve this problem.
User avatar
mpiotte
Administrator
Posts: 1961
Joined: Tue May 08, 2012 5:40 pm
Location: Montréal, Canada

Re: Problem 439

Post by mpiotte »

Maybeso83 wrote:...The solution is probably less complex than prog2, but can it really beat prog1?...
Yes. There are sublinear solutions to this problem.
Image
jpatou
Posts: 9
Joined: Sat Mar 09, 2013 8:13 am

Re: Problem 439

Post by jpatou »

I'm really struggling with this one. Can someone check if S(10^8) mod (10^9)= 575796594 ?
Thanks
Image
thundre
Posts: 356
Joined: Sun Mar 27, 2011 10:01 am

Re: Problem 439

Post by thundre »

jpatou wrote:I'm really struggling with this one. Can someone check if S(10^8)
I'm still struggling too. But I haven't asked for intermediate results because there are only 31 solvers so far.
https://projecteuler.net/fastest=439
Image
ffff0
Posts: 50
Joined: Sun Aug 21, 2011 6:26 am
Location: Moscow, Russian Federation

Re: Problem 439

Post by ffff0 »

I hope this is not too much to ask, but does this problem need a lot of memory? It obviously can't be O(n^2), but I suppose it's not O(1) either.
Image
User avatar
hk
Administrator
Posts: 12832
Joined: Sun Mar 26, 2006 10:34 am
Location: Haren, Netherlands

Re: Problem 439

Post by hk »

That depends on your implementation.
Image
War ruins the life and health of untold numbers of innocent children.
luechtdiode
Posts: 1
Joined: Tue Dec 10, 2013 9:49 pm

Re: Problem 439

Post by luechtdiode »

thundre wrote:
jpatou wrote:I'm really struggling with this one. Can someone check if S(10^8)
for me, it's still a miracle. My impl gives me the right results for the given examples. Also with S(10^8) I get the same result.
Just my final result with S(10^11) isn't accepted on PE-Page. The summed divisors are stored/calculated with BitInteger-Classes.
User avatar
Marcus_Andrews
Administrator
Posts: 1637
Joined: Wed Nov 09, 2011 5:23 pm

Re: Problem 439

Post by Marcus_Andrews »

If you are fairly certain that there is no overflow, then it could be a modular arithmetic issue instead. I'll try not to spoil this, but keep in mind that the modulus for this problem is 10^9.
benevolentdespot
Posts: 2
Joined: Thu May 11, 2017 2:41 am

Problem 439

Post by benevolentdespot »

I have a very limited experience with series and I was wondering what the equation of S(N) actually means. It doesn't have the top and parts like most series I see. I haven't taken Calculus if that is a prerequisite to solving the problem.
mdean
Posts: 206
Joined: Tue Aug 02, 2011 2:05 am

Re: Problem 439

Post by mdean »

benevolentdespot wrote: Thu May 11, 2017 3:31 am I have a very limited experience with series and I was wondering what the equation of S(N) actually means. It doesn't have the top and parts like most series I see. I haven't taken Calculus if that is a prerequisite to solving the problem.
Are you more familiar with

$$\sum_{i=1}^N \sum_{j=1}^Nd(ij)$$

Not sure if this is what you meant by "the top". The sigmas are of course a summation. The inner summation for all integers j less than or equal to N and the outer for all integers i less than or equal to N.
Image
benevolentdespot
Posts: 2
Joined: Thu May 11, 2017 2:41 am

Re: Problem 439

Post by benevolentdespot »

Thank you, that clears it up.
Post Reply