CodeChef: Codechef
Site under maintenance
  • Register
  • Forgot Password?
  • PRACTICE
    • Easy
    • Medium
    • Hard
  • COMPETE
    • August Mini Challenge
    • August Algorithm Challenge
    • July Algorithm Challenge
    • June Algorithm Challenge
    • May Gamers Challenge
  • DISCUSS
    • Forums
    • Blog
    • Twitter
  • COMMUNITY
    • CodeChef TechTalks
    • CodeChef Meetups
    • Campus Chapters
    • Host Your Contest
    • User Groups
  • HELP
    • Frequently Asked Questions
    • FAQ for Problem Setters
    • Tutorial: Paying Up
    • Tutorial: Small Factorials
    • Tutorial: Input and Output(I/O)
    • Tutorial: Your First Non-Trivial Problem
  • ABOUT
    • About CodeChef
    • About Directi
    • CEO's Corner
    • Press Room
    • Careers

Home » Problems (medium) » Box and Ball System

Box and Ball System

Problem code: BBSYSTEM

  • Submit
  • All submissions

All submissions for this problem are available.

Chef Ciel has forgotten the combination to the safe. It's a serious incident, because the safe contains this month's waitstaff salaries.

To open the safe, N boxes and N balls are used. The safe has N boxes that numbered from 1 to N uniquely. Each box can contain only one ball. Now, the box i contains one ball that numbered i, and the safe is locked.

The only things which Ciel remember for unlocking the safe are the followings:

  1. She must put every ball into some box.
  2. Let the box i contains the ball Ai. When the safe is opened the number of divisors of i equals to the number of divisors of Ai for all i from 1 to N.

How many combinations which satisfy above conditions should she check? The number of combinations can be very large, so you should print this number modulo 500009 (5*105+9).

Input

The first line contains an integer T, the number of test cases. Then T test cases follow. The only line of each test case contains an integer N.

Output

For each test case, print the number of combinations modulo 500009 (5*105+9).

Constraints

1 ≤ T ≤ 100000 (105)
3 ≤ N ≤ 2000000000 (2*109)

Sample Input

3
3
5
100

Sample Output

1
5
43264

Output details

In the first case, the valid combination is

Box: 123
Ball: 132

since the number of divisors of 2 is equal to the number of divisors of 3.

In the second case, the valid combinations are

Box: 12345 12345 12345 12345 12345
Ball: 12543 13245 13542 15243 15342


Date:2011-08-29
Time limit:3s
Source limit:50000B
Languages:All


  • Submit

Comments

Loading Comments...

SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:

Loading Submissions...

RECENT ACTIVITY FOR THIS PROBLEM:

Loading Recent Activity...

HELP

Program should read from standard input and write to standard output.

After you submit a solution you can see your results by clicking on the [My Submissions] tab on the problem page. Below are the possible results:

  • Accepted Your program ran successfully and gave a correct answer. If there is a score for the problem, this will be displayed in parenthesis next to the checkmark.
  • Time Limit Exceeded Your program was compiled successfully, but it didn't stop before time limit. Try optimizing your approach.
  • Wrong Answer Your program compiled and ran succesfully but the output did not match the expected output.
  • Runtime Error Your code compiled and ran but encountered an error. The most common reasons are using too much memory or dividing by zero. For the specific error codes see the help section.
  • Compilation Error Your code was unable to compile. When you see this icon, click on it for more information.

If you are still having problems, see a sample solution here.

  • About CodeChef
  • About Directi
  • CEO's Corner
  • Careers
  • feedback@codechef.com

© 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs

Sponsors
The time now is: