SAS002 - Apoorv and Math problem

Apoorv is an expert in maths .There are very few questions in maths that Apoorv is unable to answer.Apoorv's teacher is not very fond of Apoorv.So he decided to give Apoorv a  function value to calculate.Apoorv is unable to solve this problem and turns to you for help.Help him to find the answer to the function quickly.Apoorv's teacher will only check the final answer.So Apoorv is free to do calculate the value by any function he likes but the final answer should be same.Also as his teacher don't like him much he gave him a very strict time limit to solve the problem.Help Apoorv in finding the answer quickly.

The function given by Apoorv's teacher is as follows:

function(number) {
              answer = 1
              for ( each i from 1 to number) {
                   if( number modulo i is 0  ) {
                       answer=answer multiplied by i 
              return answer
At max 100 numbers will be given by Apoorv's teacher.
The value of number given by Apoorv's teacher will easily fit into 64 bit-integer and will always be positive.


First line will contain t denoting t numbers that are given by Apoorv's teacher.

Next t lines will contain a single integer denoting the number.


For each t numbers output the value of answer in new line.Since the value of answer can be very large Apoorv's teacher is fine with you reporting the answer modulo 109+7.


Output: 1

hide comments
sas1905: 2017-12-04 19:07:02

Edit :@ nadstratosfer: Glad you liked the problem :)

Last edit: 2017-12-05 07:17:57
nadstratosfer: 2017-12-04 12:44:50

sas1905, please let me know which case my code fails on. It seems to be passing all the traps I can throw at it. BTW not sure if such cases are in testfiles but for n >= 2^63 judge solution appears to break.

Edit: Thanks Sasmit, got AC with the same code indeed... And again many WA's on retry ;) Great problem, postponed a bunch of errands so I could wrestle with it.

Last edit: 2017-12-04 22:52:30
trijeet: 2017-10-25 01:03:56

Great Problem ! AC in 5th go ;)

visleck: 2017-08-16 17:52:29

@sas1905 can u tell me where I am going wrong.I believe I am doing it correctly

sas1905: 2017-08-16 09:17:52

@pvsmpraveen going by the constraints I don't think so.

sas1905: 2017-08-16 09:15:11

@amulyagaur the number is positive and constraint range is range of 64 bit integer.

amulyagaur: 2017-08-16 08:50:31

@sas1905 what are the specific constraints??

harsh_verma: 2017-08-15 11:03:43

really good 1 :)

divyanshjr: 2017-08-15 10:05:34

Sas pro! Please don't call it an easy problem.. :P

pvsmpraveen: 2017-08-15 07:26:50

Nice Question AC in 2 go :)
@sas1905 is there easy way to solve it other than what i did?

Added by:sas1905
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Resource:College Contests.