F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Problem D. Permutation

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 124    Accepted Submission(s): 32


Problem Description
An array P = [$p_1$, $p_2$, ..., $p_n$] is a “n-permutation”, if and only if all pi are in [1, n] and distinct.
For a n-permutation P, we define a transform function F on P: F(X) = [$X_{p_1}$, $X_{p_2}$, ..., $X_{p_n}$]. The result is obviously also a n-permutation.
It is not hard to find that if we apply F on P repeatedly, the result will be same as the original P at certain time. Formally, we define $F^0$(X) = X, and $F^{i+1}$(X) = F($F^i$(X)), then we use G(P) to represent
the minimum positive number which satisfy $F^{G(P)}$(X) == X. (Two n-permutations are equal (“==”), ifand only if their corresponding elements are equal. )
Among all n! different n-permutations, how many distinct values of G are there?
 

Input
Input is given from Standard Input in the following format:
T
$n_1$
$n_2$
...
...
...
$n_T$
Constraints
1 ≤ T ≤ 3000
1 ≤ n ≤ 3000
 

Output
Print T line denotes the answers.
Each line contains the number of distinct values of G($P_i$), where $P_i$ enumerates all $n_i$-permutations.
The answer maybe very large, you should modulo 1000000007(10^9 + 7)
 

Sample Input
3 1 2 3
 

Sample Output
1 2 3
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 16:06:46, Gzip enabled