LOCKER - Magic of the locker

no tags 

Vertu, the clever businessman, sells the ropes to his customers at the rate of 1 rupee per meter. He can only sell an integer length of a rope to a customer. Also, he has a magic locker which functions this way:
    Suppose the locker has 'x' rupees. Now if 'y' rupees more are put into this locker, it multiplies them and total money in the locker now is 'x*y'.
This morning, Vertu starts his bussiness with 'n' meters of rope. He puts 1 rupee in the locker as to have good luck.
Find the maximum money he can earn today considering that he sold all of his rope at the end of the day.

NOTE: Vertu has to put all rupees into the locker as soon as he gets it, and can get rupees from locker only at the end of the day.

Input  and Output

The first line contains t, the number of test cases. t lines follow, each containing one positive integer n. For each of these integers, print the required answer modulo(109+7).

Constraints

t<105

0<n<1012

Example

Input:
2
4
5
Output: 4
6

hide comments
abhishek_565: 2020-09-23 11:01:34

@heisenburg Thanks man that article saved me. I was using 2 instead of 3. Anyone still stuck give this a go: https://medium.com/@palak001/spoj-locker-magic-of-the-locker-a758bccf432f

sabbir0152: 2020-07-03 09:12:47

incomplete problem ...

heisunbug: 2020-06-05 11:24:35

Also take care of base case

heisunbug: 2020-06-05 10:50:15

If you aren't able to solve this then refer https://medium.com/@palak001/spoj-locker-magic-of-the-locker-a758bccf432f

shuhbo: 2020-05-13 19:41:36

Don't really understand. Python gives me TLE, but c++ gives me accepted.

anurag_mishra: 2020-04-25 03:19:24

modular exponentiation... AC

whoopwhoop: 2020-04-16 10:51:45

@lalitkundu please tell why am i getting a wa my submission id is 25779593

ajay_panchal: 2020-03-27 08:34:03

test case ?

HVK: 2019-09-27 13:10:59

*Redacted*

Last edit: 2019-09-27 13:11:12
nodir: 2019-08-16 16:20:56

I finally got ACCEPTED.
I think that If there is a function in your code that returns nothing your code gets ERRORs on this site.


Added by:darkshadows
Date:2013-03-28
Time limit:1s
Source limit:5000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Own problem