Problem 258
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.
-
zwuupeape
- Posts: 189
- Joined: Tue Jun 09, 2009 6:11 pm
Problem 258
Hey. Can anyone please confirm my result?
I use the same parameters (modulo 20092010, find gk for k = 10 ^ 18), except:
gk = 1 if 0 <= k <= 10
gk = g(k-10) + g(k-9) for k > 10
I get 11649166.
For modulo 260, find gk for k = 10 ^ 16, gk = 1 if 0 <= k <= 30 else gk = g(k-30) + g(k-29), I get 145.
Correct ??
I use the same parameters (modulo 20092010, find gk for k = 10 ^ 18), except:
gk = 1 if 0 <= k <= 10
gk = g(k-10) + g(k-9) for k > 10
I get 11649166.
For modulo 260, find gk for k = 10 ^ 16, gk = 1 if 0 <= k <= 30 else gk = g(k-30) + g(k-29), I get 145.
Correct ??
-
bladewang
- Posts: 1
- Joined: Sun Oct 04, 2009 7:50 pm
Re: Problem 258 confirmation
I found g(k) == 2(k/2000), if k is a multiple of 2000
and
g(1018) == 2(5*10^14)
so, the answer is same to
2(5*10^14) mod 20092010
It's my code in Python:
the result is 8340206
it's wrong ……
WHY ???

and
g(1018) == 2(5*10^14)
so, the answer is same to
2(5*10^14) mod 20092010
It's my code in Python:
Code: Select all
n = 20092010
print (((2**10000%n)**100000%n)**100000%n)**5%n
it's wrong ……
WHY ???
-
zwuupeape
- Posts: 189
- Joined: Tue Jun 09, 2009 6:11 pm
Re: Problem 258 confirmation
This is incorrect. It is only true for k < 2000*2000.
Also, you might consider using Python's built-in modular exponentiation, you don't have to raise the number to the power and then take the modulo.
Also, you might consider using Python's built-in modular exponentiation, you don't have to raise the number to the power and then take the modulo.
-
quilan
- Posts: 182
- Joined: Fri Aug 03, 2007 11:08 pm
Re: Problem 258 confirmation
Yupyup... pow(a,b,m) is awesome. Learn it, live it, love it.zwuupeape wrote:Also, you might consider using Python's built-in modular exponentiation, you don't have to raise the number to the power and then take the modulo.
ex ~100%'er... until the gf came along.


- Jochen_P
- Posts: 55
- Joined: Mon Oct 05, 2009 10:47 am
- Location: Stuttgart, Germany
Re: Problem 258 confirmation
Yeah, this will print the wrong result in no time
this one too:
Can Anyone confirm 22189656 for k = 1010 ?
Code: Select all
n = 20092010
print pow(pow(pow(pow(2,10000,n),100000,n),100000,n),5,n)
Code: Select all
print pow(2,10**18/2000, 20092010)
Last edited by Jochen_P on Thu Oct 08, 2009 3:14 pm, edited 1 time in total.

-
harryh
- Posts: 2091
- Joined: Tue Aug 22, 2006 9:33 pm
- Location: Thessaloniki, Greece
- Jochen_P
- Posts: 55
- Joined: Mon Oct 05, 2009 10:47 am
- Location: Stuttgart, Germany
Re: Problem 258 confirmation
dang!
thanx
[edit] removed other result as it was implausible ?
thanx
[edit] removed other result as it was implausible ?
Last edited by Jochen_P on Thu Oct 08, 2009 3:48 pm, edited 1 time in total.

-
zwuupeape
- Posts: 189
- Joined: Tue Jun 09, 2009 6:11 pm
-
quilan
- Posts: 182
- Joined: Fri Aug 03, 2007 11:08 pm
Re: Problem 258 confirmation
You've got some wrong approaches here, but it strikes me as somewhat silly such that 22189656 > 20092010. Your end result is greater than your modulus?Jochen_P wrote:Can Anyone confirm 22189656 for k = 1010 ?
ex ~100%'er... until the gf came along.


-
quilan
- Posts: 182
- Joined: Fri Aug 03, 2007 11:08 pm
Re: Problem 258 confirmation
So, I solved the problem and I don't want to pollute the board for it by asking for help, but could some kindly soul PM me about how in the heck the method the majority of people used works? I must have completely missed that entire section in my lin-alg classes.
Edit: Got the idea behind the main idea thanks to zwuupeape but still confused about the identity named in the first post.
Edit2: Got it now. Thanks guys, you rock!
Edit: Got the idea behind the main idea thanks to zwuupeape but still confused about the identity named in the first post.
Edit2: Got it now. Thanks guys, you rock!
Last edited by quilan on Fri Oct 09, 2009 1:53 pm, edited 1 time in total.
ex ~100%'er... until the gf came along.


- daniel.is.fischer
- Posts: 2400
- Joined: Sun Sep 02, 2007 11:15 pm
- Location: Bremen, Germany
Re: Problem 258 confirmation
Explanation sent, hope that clarifies it.quilan wrote:Edit: Got the idea behind the main idea thanks to zwuupeape but still confused about the identity named in the first post.
Il faut respecter la montagne -- c'est pourquoi les gypaètes sont là.
- Jochen_P
- Posts: 55
- Joined: Mon Oct 05, 2009 10:47 am
- Location: Stuttgart, Germany
Re: Problem 258 confirmation
Um, yeah, that was a silly mistake in the generator, which impelemented the modulus calc in each step but returned twice the modulus ... didn't even realize the result was greater than the modulusquilan wrote:You've got some wrong approaches here, but it strikes me as somewhat silly such that 22189656 > 20092010. Your end result is greater than your modulus?Jochen_P wrote:Can Anyone confirm 22189656 for k = 1010 ?
I stopped working on this problem completely and deleted my efforts so far. Will return to it when I am less silly

-
viv_ban
- Posts: 23
- Joined: Mon May 26, 2008 3:09 pm
Re: Problem 258
Can somebody please confirm my result. For
gk = 1 for k = 0 to 14
gk = (gk-14+ gk-15) mod 10^6 for k>= 15
I got g10^18 = 336460
gk = 1 for k = 0 to 14
gk = (gk-14+ gk-15) mod 10^6 for k>= 15
I got g10^18 = 336460
-
zwuupeape
- Posts: 189
- Joined: Tue Jun 09, 2009 6:11 pm
-
viv_ban
- Posts: 23
- Joined: Mon May 26, 2008 3:09 pm
Re: Problem 258
Thanks zwuupeape.
Is it possible to solve this question in less than 1 min?
I need to perform around 70*20003 operations and I don't think python can perform this many operations with in 1 min. Even after optimization I can reduce total operations to 70*20002.8 which again is not enough to solve the problem in1 min.
Is there exist a better algorithm? If so what kind of order should I be looking for?
Is it possible to solve this question in less than 1 min?
I need to perform around 70*20003 operations and I don't think python can perform this many operations with in 1 min. Even after optimization I can reduce total operations to 70*20002.8 which again is not enough to solve the problem in1 min.
Is there exist a better algorithm? If so what kind of order should I be looking for?
- hk
- Administrator
- Posts: 12832
- Joined: Sun Mar 26, 2006 10:34 am
- Location: Haren, Netherlands
Re: Problem 258
There exists an O(n2) method.

War ruins the life and health of untold numbers of innocent children.
-
ThomasH
- Posts: 117
- Joined: Sun Mar 26, 2006 8:41 am
- Location: Berlin, Germany
Re: Problem 258
I do have the same problem that quilan had: I solved the problem (in very LONG runtime) and gained access to the forum, but I have no idea, why the method i.e. of the first post is working. Could some kindly soul PM me some hints for further reading?
-
quilan
- Posts: 182
- Joined: Fri Aug 03, 2007 11:08 pm
Re: Problem 258
I'll send some info once I get into work this morning...ThomasH wrote:I do have the same problem that quilan had: I solved the problem (in very LONG runtime) and gained access to the forum, but I have no idea, why the method i.e. of the first post is working. Could some kindly soul PM me some hints for further reading?
ex ~100%'er... until the gf came along.


-
ThomasH
- Posts: 117
- Joined: Sun Mar 26, 2006 8:41 am
- Location: Berlin, Germany
Re: Problem 258
quilan, thank you very much for your quick response - and a warm thank you, too, to daniel.is.fischer und zwuupeape, who were quoted by quilan.
-
OskarS
- Posts: 6
- Joined: Tue Nov 01, 2011 11:17 pm
Re: Problem 258
Can I just ask a quick question:
In order to solve this problem, do you at any point need to deal with complex numbers? Because the way I'm doing it, you have to, but I'm starting to think that I've might have gone down the wrong alley here.
If anyone could either reply or PM me with the answer, I'd be mighty grateful. Just a yes or no needed (though I wouldn't turn down more help, obviously
. Thanks!
In order to solve this problem, do you at any point need to deal with complex numbers? Because the way I'm doing it, you have to, but I'm starting to think that I've might have gone down the wrong alley here.
If anyone could either reply or PM me with the answer, I'd be mighty grateful. Just a yes or no needed (though I wouldn't turn down more help, obviously