Problem 822

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
User avatar
zilet
Posts: 5
Joined: Tue Apr 12, 2022 10:00 am
Location: Poland, Niemcz

Problem 822

Post by zilet »

Problem 822 – Square the Smallest

This problem assumes the following operations:
  1. compare numbers in a list to find the smallest
  2. square the number
  3. repeat 1016 times
  4. sum numbers from the list
As multiple squaring of the numbers makes them soon very big, we are suggested (very wisely) to give the result modulo 1234567891.

My question is: are we expected to apply modulo 1234567891:
  1. In the step 2 already? – So each calculated square is possibly made smaller before replacing it's predecessor in the list.
  2. In the step 4 only? – While summing the list.
I found the trick to optimise high powers of numbers modulo 1234567891, but if in the step 1 I must compare original numbers (without modulo) I can not benefit from my optimization trick :?
Or am I missing something?
Image
User avatar
bruce_love
Administrator
Posts: 3540
Joined: Sat Sep 24, 2011 11:59 am

Re: Problem 822

Post by bruce_love »

Thanks for your interest in this problem I hope you are enjoying it.

Use the modulus in step 4 only - so you can't use your optimising trick (or can you).
User avatar
zilet
Posts: 5
Joined: Tue Apr 12, 2022 10:00 am
Location: Poland, Niemcz

Re: Problem 822

Post by zilet »

bruce_love wrote: Sun Mar 03, 2024 9:23 pm Use the modulus in step 4 only - so you can't use your optimising trick (or can you).
I could use my trick if all the list elements are either raised to the same power or I could predict their final powers. But the final powers of list elements are neither equal nor predictable, as the lower the value of the element list, the higher the power. So before the last (1016th) comparison, I could not predict the final power of each element, so I could not decide about using the trick (or could I). :)
Image
User avatar
zilet
Posts: 5
Joined: Tue Apr 12, 2022 10:00 am
Location: Poland, Niemcz

Re: Problem 822

Post by zilet »

I solved the problem.
zilet wrote: Mon Mar 04, 2024 7:34 am But the final powers of list elements are neither equal nor predictable, [...]
They are not equal, but they are predictable, of course! :)
Image
Post Reply