Problem 250
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.
- Lord_Farin
- Posts: 239
- Joined: Wed Jul 01, 2009 10:43 am
- Location: Netherlands
Problem 250
I have been spending a lot of time on this problem the last few days, and I am pretty certain that my approach is correct, and that the code that I use for it is also correct. In spite that, the answer is rejected. Is there someone whom would be willing to take a peek at my (Mathematica) code?

-
zwuupeape
- Posts: 189
- Joined: Tue Jun 09, 2009 6:11 pm
Re: Problem 250
Make sure you did not include the empty set - by convention it sums up to 0 which is divisible by 250
- Lord_Farin
- Posts: 239
- Joined: Wed Jul 01, 2009 10:43 am
- Location: Netherlands
Re: Problem 250
I have included the empty set in my calculations and considerations, nonetheless the answer is wrong... Also, my algorithm yields the correct answer for any trivial case I can think of and compute by hand. Thus disappointed, I thoroughly reconsidered my algorithm, only to confirm that I completely agree with it, and that it should work.

-
Hippunky
- Posts: 6
- Joined: Sat Feb 26, 2011 10:36 pm
Re: Problem 250
I've gotten (very easy I know!) the count of each of the mod 250 values of x^x for x in 1..250250, e.g. 25025 "x^x"'s result in 0 mod 250, 1001 "x^x"'s result in 1 mod 250 etc.
Any suggestions as to the next step to take? Please be vagueish as I don't want a solution - just an idea of where to go from here. This problem has bugged me for a long time - I'm sure there's something I can do with these "counts of "powers mod 250"" - but everything I think of implies a prohibitive run time so I'm missing something!
Thanks,
Will (Hippunky).
Any suggestions as to the next step to take? Please be vagueish as I don't want a solution - just an idea of where to go from here. This problem has bugged me for a long time - I'm sure there's something I can do with these "counts of "powers mod 250"" - but everything I think of implies a prohibitive run time so I'm missing something!
Thanks,
Will (Hippunky).
-
sivakd
- Posts: 217
- Joined: Fri Jul 17, 2009 9:37 am
- Location: California, USA
- Contact:
Re: Problem 250
Did you solve Problem 249? Solve one, and you will be able to solve the other with minimal effort.

puzzle is a euphemism for lack of clarity
-
Hippunky
- Posts: 6
- Joined: Sat Feb 26, 2011 10:36 pm
Re: Problem 250
Hi Sivakd - yes, I did (eventually) solve 249, am not sure my solution will scale to 250250 elements, but perhaps I've dismissed that out of hand - I'll give it a try and will let you know how it goes.
Thanks!
Will.
Thanks!
Will.
-
Hippunky
- Posts: 6
- Joined: Sat Feb 26, 2011 10:36 pm
Re: Problem 250
The approach I took to problem 249 doesn't scale to problem 250, at least not yet. 
I hope the below isn't considered a spoiler as it's prohibitively slow!
My approach to 250 thus far has been:
Perform (x^x) Mod 250 for all of the numbers. Maintain a set of the resultant values together with the number of times each value appears, e.g. {(0, 25025), (1, 1001), (3, 1001), ...}.
I iterate over this set of mod-freq pairs, for each pair (a, b) adding a * 1, 2, 3, ..., b to all sums achieved for lower values of a - and maintaining the frequency by using nCr * "frequency of earlier sum" (nCr is optimized to be really fast - the calculation of nCr (mod 1e16) isn't the bottleneck). My bottleneck is calculating (nCr * "frequency of earlier sum") mod 1e16 - as nCr and the freq. are both 64-bits - but I feel that even if I remove this bottleneck, the approach will still be really slow.
Should I instead be looking for an approach that answers the question 'how many ways can 250*x be written using 25025 0's, 1001 1's, 1001 3's, etc.' in a quick manner?
Any hints (no spoilers, please!) much appreciated!
Regards,
Will.
I hope the below isn't considered a spoiler as it's prohibitively slow!
My approach to 250 thus far has been:
Perform (x^x) Mod 250 for all of the numbers. Maintain a set of the resultant values together with the number of times each value appears, e.g. {(0, 25025), (1, 1001), (3, 1001), ...}.
I iterate over this set of mod-freq pairs, for each pair (a, b) adding a * 1, 2, 3, ..., b to all sums achieved for lower values of a - and maintaining the frequency by using nCr * "frequency of earlier sum" (nCr is optimized to be really fast - the calculation of nCr (mod 1e16) isn't the bottleneck). My bottleneck is calculating (nCr * "frequency of earlier sum") mod 1e16 - as nCr and the freq. are both 64-bits - but I feel that even if I remove this bottleneck, the approach will still be really slow.
Should I instead be looking for an approach that answers the question 'how many ways can 250*x be written using 25025 0's, 1001 1's, 1001 3's, etc.' in a quick manner?
Any hints (no spoilers, please!) much appreciated!
Regards,
Will.
-
sivakd
- Posts: 217
- Joined: Fri Jul 17, 2009 9:37 am
- Location: California, USA
- Contact:
Re: Problem 250
Will, check the private forum for 249 to get some ideas on other ways of solving this type of problems.

puzzle is a euphemism for lack of clarity
-
Hippunky
- Posts: 6
- Joined: Sat Feb 26, 2011 10:36 pm
-
psujono
- Posts: 7
- Joined: Sun Mar 18, 2012 8:09 am
- hk
- Administrator
- Posts: 12832
- Joined: Sun Mar 26, 2006 10:34 am
- Location: Haren, Netherlands
Re: Problem 250
An empty set is a set with no elements.
So a non-empty set has at least one element.
A non empty subset of {1^1, 2^2, 3^3,..., 250250^250250} has at least one element of the form a^a with a from 1..250250.
See also Subset
So a non-empty set has at least one element.
A non empty subset of {1^1, 2^2, 3^3,..., 250250^250250} has at least one element of the form a^a with a from 1..250250.
See also Subset

War ruins the life and health of untold numbers of innocent children.
-
thkang
- Posts: 8
- Joined: Thu Nov 15, 2012 8:34 am
Re: Problem 250
I solved problem 249 and 250 with same method, only tweaking parameters.
249 was the problem I solved first, but my method worked better and faster for 250, since only 250 values are stored in my array, compared to 1450000 values for 249.
Both problems are good and if you know more about modular arithmetic and so(unfortunately I'm not), you might be able to come up with solutions better than mine!
249 was the problem I solved first, but my method worked better and faster for 250, since only 250 values are stored in my array, compared to 1450000 values for 249.
Both problems are good and if you know more about modular arithmetic and so(unfortunately I'm not), you might be able to come up with solutions better than mine!
- yourmaths
- Posts: 47
- Joined: Mon Aug 25, 2014 11:00 am
Re: Problem 250
I just solved 249 and 250. While 249 is probably easier to understand, 250 is (can be?!) definitely the easier problem computationally!
level = lambda number_solved: number_solved // 25


-
enigmaticcam
- Posts: 16
- Joined: Wed Sep 30, 2015 12:07 am
Re: Problem 250
Suppose I have a set that totals to 250, say {1^1 + 249^249}. Would there exist a similar set with a zero, say {1^1 + 249^249 + 250^250}? In fact, since there are 25,025 ways where x^x % 250 = 0, then for any set that total to 250 that doesn't have any zeros, there exist many other sets that use the same elements plus all combinations of elements that sum to 0? Is that correct?
