CodeChef is a non-commercial competitive programming community
Login
Username (New User? Signup) Password (Forgot Password?)
Signup
Login or
Signup with
Connect
Note
  • Publicize your achievements on your Facebook Wall.
  • Challenge your friends or ask them for help.

Site Navigation

  • PRACTICE
    • Easy
    • Medium
    • Hard
    • Challenge
    • Peer
  • COMPETE
    • All Contests
    • June Long 2012
    • May Cook-Off
    • May Long 2012
  • DISCUSS
    • Forums
    • Blog
    • Wiki
    • Facebook
    • Twitter
  • COMMUNITY
    • CodeChef Meetups
    • Campus Chapters
    • Host your Contest
    • User Groups
    • CodeChef TechTalks
    • All Educational Initiatives
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Problem Setting
    • Tutorials
    • Long Contest Ranks
    • Short Contest Ranks
    • Event Calendar
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • Contact Us
    • About Directi
Home » Compete » June 2009 (Contest IV) » Product of divisors

Product of divisors

Problem code: D1

  • All Submissions

All submissions for this problem are available.

A tutorial for this problem is available here

Being in love with number theory, Johnny decided to take a number theory course. On the first day, he was challenged by his teacher with the following problem: given a number N, compute the product of its positive divisors. Johnny is desperate to impress his new teacher so he asks you for help.

In this problem, the divisors of N do not include the number N itself. For example, if N=12, the divisors of N (excluding N) are 1, 2, 3, 4, and 6. Thus, the product of divisors is 1x2x3x4x6=144. Since the result may be very large, if the result has more than 4 decimal digits, Johnny only needs to compute the last 4 digits of it.

Input

The first line contains t, the number of test cases (about 300,000). Then t test cases follow.

Each test case contains a single integer N (1<=N<=500,000) whose product of divisors needs to be computed.

Output

For each test case, print a single line containing the corresponding result of that test case.

Example

Input
6
3
4
12
25
957
10000

Output
1
2
144
5
7493
0000


Author: admin
Date Added: 5-05-2009
Time Limit: 2 sec
Source Limit: 50000 Bytes
Languages: ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TEXT, WSPC


  • Submit

Comments

  • Login or Register to post a comment.

nickless @ 2 Jun 2009 05:16 PM

what should be the answer for 1

xylestr @ 2 Jun 2009 05:22 PM

obviously, ans for 1 is 1.

mydearestvj @ 2 Jun 2009 05:53 PM

I'm not so sure. I'm getting wrong answer although I've checked my program with the output of a brute force program for 1 to 500,000. Perhaps I'm doing something wrong with the formatting but I've checked it many times. I guess there is an issue with outlier cases.

drakknight @ 2 Jun 2009 06:00 PM

why it is obvious ? the divisors of N do not include the number N itself
then set is empty when what is product of members of set ?
sounds cryptic

kyun @ 2 Jun 2009 06:35 PM

@Kundan

I had a similaar issue, its certainly not obvious. But Bharat is right. The answer for 1 is 1.

nickless @ 2 Jun 2009 07:18 PM

@Vijay .... I also checked all the answers by brute force and its the same... i took the number of testcases to be 500,000 and then checked for all number till 500000.

I was only doubtful about 1. So is there any way that i can check if i have mistaken in the output format

abhirama @ 2 Jun 2009 07:50 PM

The time limit of n seconds is for the entire test case right, as in if there are 10 test cases all 10 have to be solved in n seconds?

kprateek88 @ 2 Jun 2009 08:07 PM

@divyanshu: The empty product is taken to be 1. Like the empty sum is 0. Like anything to the power 0 is 1. Like 0 times anything is 0.

al_man @ 2 Jun 2009 08:36 PM

Last line of output is "0000".why??
Why can't it be "0". Just to check for output format errors :)
sm1 plz temme

fushar @ 2 Jun 2009 10:23 PM

because the product is greater than 9999 and its last 4 digits are '0000'.

param @ 3 Jun 2009 02:08 AM

Time Limit Exceeded.... Wat may b d reasons for this issue ? Can any1 plz tel me ??

supercharger @ 3 Jun 2009 03:26 AM

In java, outputting 300000 values itself taking time. I did even use BufferedOutputStream....

rahul_singh @ 3 Jun 2009 09:34 AM

hey guys I'm new here. I write my code in C. But the program works somewhat differently for different compilers. Its mentioned that here gcc 4.0.0-8 is used. Can anyone tell me how to get it?

pdah @ 3 Jun 2009 01:38 PM

In C , outputting 300000 values without any calculation gave me TLE, don't now what to do then

catchmrbharath @ 3 Jun 2009 07:49 PM

any ideas in c to reduce time

xazker @ 3 Jun 2009 11:10 PM

don't use cin\cout

rahulakaneo @ 4 Jun 2009 12:46 AM

Even I don't understand this . How can one output 300000 values within two seconds ? Is 2 seconds , the time limit for a single test case or for all cases included ? Please clear my doubt Chef .. !!

supercharger @ 4 Jun 2009 12:56 AM

In Java, While program logic taking 0.8S, outputting the values taking more than 3.2s causing TLE

supercharger @ 4 Jun 2009 01:06 AM

@Anoop kumar, you are damaging spirit of contest. please do not post code.

innocentboy @ 4 Jun 2009 02:05 AM

@Rahul Gulati
At least 40 people have done it. 2 seconds is time limit for all test cases included I think.

rahulakaneo @ 4 Jun 2009 02:40 AM

@Ajay
Thanks :) I was thinking of that only ..

i_abhishek @ 5 Jun 2009 01:19 AM

hey i've checked my program using the brute force method but still it is saying incorrect answer... i checked for all the cases but all of them are correct.. any suggestions about in which test case the program would've failed.. or is it some formatting error ??

ekta @ 5 Jun 2009 10:49 PM

hey guys I'm new here. I write my code in C. But the program works somewhat differently for different compilers. Its mentioned that here gcc 4.0.0-8 is used. Can anyone tell me how to get it?

rmsh @ 7 Jun 2009 12:17 AM

I checked the solutions many times, still showing wrong answer. What could be the problem.

yogu13 @ 7 Jun 2009 08:55 PM

i have a solution which comes around 1.8 secs .. but strangely the codechef system keeps rejecting it for TLE... Anyone has any ideas on this ???

admin 2 @ 8 Jun 2009 08:43 PM

@Yogesh The server config might not be the same as yours and hence you can assume the server to be slower.

tpb261 @ 9 Jun 2009 04:02 AM

hey guys I see you ppl do it differently
For 957 with factors 3, 11, 29 the product of divisors is 915849
but the answer is given is 7493. Though doable I guess you should be considering both solutions.

tpb261 @ 9 Jun 2009 04:08 AM

OOPssssssss My mistake Sorry guys........ :D

rajesh_yadav @ 9 Jun 2009 11:45 AM

might be some prob with evaluater,
it says time limit exceed, and i checked it I found wrong output was given by the pro, instead of showing correct respose i.e. wrong answer it is displaying time limit exceed , how to become sure weather really time limit exceed or test case failed

kothari2015 @ 9 Jun 2009 08:05 PM

wat does runtime error NZEC means?
i have used python 2.6 instead of 2.5 as given in the options for languages here, is that creating a problem?
the code runs well on my system!

bvlobx @ 9 Jun 2009 09:31 PM

whts wrong with the system???
I jst tried to output default answer without calculating anything..
but just to output the answer it is saying time limit exceeded!!!!

kothari2015 @ 10 Jun 2009 02:29 AM

plz help me !!
question posted earlier.

saurabhh @ 10 Jun 2009 04:25 AM

^you can check for it in the help section.

kothari2015 @ 10 Jun 2009 05:31 AM

i cant find help there.
the code is running properly giving correct output for the given example inputs!!!!
HELP!!!!!!!!!!

kothari2015 @ 10 Jun 2009 05:39 AM

are there compilers available for python language or i m wasting my time here!!!!!!

saurabhh @ 10 Jun 2009 05:46 AM

Program is working on my pc but here it is reporting SIGSEGV error, help.
Made necessary changes but still the same.

admin 2 @ 10 Jun 2009 05:08 PM

Some of you guys may feel that the time limit is slightly restrictive, but a well coded solution will be accepted. That is the intent of this problem.

ambar @ 11 Jun 2009 11:26 PM

Has the submission been stopped? But I can see some members have submitted some hours back!
Please help me if I am missing something!!!

kumaranurag @ 14 Jun 2009 05:28 AM

can i submit the code now.
i just want to check whetreh my code is good.?

nandish_83 @ 14 Jun 2009 09:51 PM

Why is the solution submission option removed? We can still see few users uploading their solutions. Please let us know. Your response would be highly appreciated

Very simple

jassi9c @ 23 Aug 2009 02:12 AM
Very simple

SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:

Programming Competition Fetching successful submissions
Directi Go for Gold
CodeChef is a global programming communityCodeChef hosts online programming competitions
CodeChef is a non-commercial competitive programming community
  • About CodeChef
  • About Directi
  • CEO's Corner
  • C-Programming
  • Programming Languages
  • Contact Us
© 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs
In order to report copyright violations of any kind, send in an email to copyright@codechef.com
CodeChef a product of Directi
The time now is:
CodeChef - A Platform for Aspiring Programmers

CodeChef was created as a platform to help programmers make it big in the world of algorithms, computer programming and programming contests. At CodeChef we work hard to revive the geek in you by hosting a programming contest at the start of the month and another smaller programming challenge in the middle of the month. We also aim to have training sessions and discussions related to algorithms, binary search, technicalities like array size and the likes. Apart from providing a platform for programming competitions, CodeChef also has various algorithm tutorials and forum discussions to help those who are new to the world of computer programming.

Practice Section - A Place to hone your 'Computer Programming Skills'

Try your hand at one of our many practice problems and submit your solution in a language of your choice. Our programming contest judge accepts solutions in over 35+ programming languages. Preparing for coding contests were never this much fun! Receive points, and move up through the CodeChef ranks. Use our practice section to better prepare yourself for the multiple programming challenges that take place through-out the month on CodeChef.

Compete - Monthly Programming Contests and Cook-offs

Here is where you can show off your computer programming skills. Take part in our 10 day long monthly coding contest and the shorter format Cook-off coding contest. Put yourself up for recognition and win great prizes. Our programming contests have prizes worth up to Rs.20,000 and $700lots more CodeChef goodies up for grabs.

Discuss

Are you new to computer programming? Do you need help with algorithms? Then be a part of CodeChef's Forums and interact with all our programmers - they love helping out other programmers and sharing their ideas. Have discussions around binary search, array size, branch-and-bound, Dijkstra's algorithm, Encryption algorithm and more by visiting the CodeChef Forums and Wiki section.

CodeChef Community

As part of our Educational initiative, we give institutes the opportunity to associate with CodeChef in the form of Campus Chapters. Hosting online programming competitions is not the only feature on CodeChef. You can also host a coding contest for your institute on CodeChef, organize an algorithm event and be a guest author on our blog.

Go For Gold

The Go for Gold Initiative was launched about a year after CodeChef was incepted, to help prepare Indian students for the ACM ICPC World Finals competition. In the run up to the ACM ICPC competition, the Go for Gold initiative uses CodeChef as a platform to train students for the ACM ICPC competition via multiple warm up contests. As an added incentive the Go for Gold initiative is also offering over Rs.8 lacs to the Indian team that beats the 29th position at the ACM ICPC world finals. Find out more about the Go for Gold and the ACM ICPC competition here.

Domain Name Registration, Web hosting, and Website Design provided by BigRock.com