Golden cornucopia

Discuss about the puzzles, but without giving the solutions please !!!

Golden cornucopia

Postby admin » Thu May 19, 2011 7:41 pm

You have found the golden cornucopia, lucky you. This magic device multiplies coins according to its own magical rule. The magical rule is simple, when you insert p coins in the cornucopia, it returns the initial p coins plus the coins produced by entering p-1,p-2,...,p-7 coins in the cornucopia.



Since the number of coins returned by the cornucopia is extremely large, the goal is to write a program to return that number modulo 1000000007.




User avatar
admin
Site Admin
 
Posts: 333
Joined: Thu Dec 23, 2010 1:27 am

Re: Golden cornucopia

Postby MimiEA » Fri May 20, 2011 8:08 am

I was wondering if we were adding the negative number of coins when P-i < 0 also or just consider it to be 0 (which i think is the cases)
User avatar
MimiEA
 
Posts: 1
Joined: Fri May 20, 2011 1:35 am

Re: Golden cornucopia

Postby admin » Fri May 20, 2011 7:48 pm

Yes, negative values become 0.
User avatar
admin
Site Admin
 
Posts: 333
Joined: Thu Dec 23, 2010 1:27 am

Re: Golden cornucopia

Postby NeoRea » Sun May 22, 2011 10:20 pm

I think the example's output is wrong. For 9 inserted coins there is a result 510 but instead i think it should be 511.
User avatar
NeoRea
 
Posts: 13
Joined: Mon Jan 17, 2011 10:27 am

Re: Golden cornucopia

Postby admin » Mon May 23, 2011 5:31 am

Are you sure or did you figure it out after asking the question ?
User avatar
admin
Site Admin
 
Posts: 333
Joined: Thu Dec 23, 2010 1:27 am

Re: Golden cornucopia

Postby NeoRea » Wed May 25, 2011 9:35 am

admin wrote:Are you sure or did you figure it out after asking the question ?

I've missed ",p-7" when i was reading description. Imo, p-1,p-2,... would be quite easier and saves few lines of code ;)
User avatar
NeoRea
 
Posts: 13
Joined: Mon Jan 17, 2011 10:27 am

Re: Golden cornucopia

Postby Alexey Solodovnikov » Tue Jun 12, 2012 2:43 pm

Additional testcase:

7
1
2
3
4
5
10
100000

Output:

1
3
7
15
31
1018
636392404
User avatar
Alexey Solodovnikov
 
Posts: 32
Joined: Sun Jun 26, 2011 5:54 am

Re: Golden cornucopia

Postby anu_chat » Fri Dec 28, 2012 10:25 am

thanks!
User avatar
anu_chat
 
Posts: 1
Joined: Fri Dec 28, 2012 8:37 am


Return to Puzzles

Who is online

Users browsing this forum: No registered users and 3 guests

cron