NYOJ-127 Stargate (1)
Stargate (1) Time Limit: 3000 MS | memory limit: 65535 KB difficulty: 3
-
Description
-
In 3000 AD, zvirtual Empire led N galaxy systems, which were originally traveling near a beam ship. Recently, Dr. X invented the Stargate, which uses the wormhole technology, A worm hole can connect any two galaxy, so that people don't have to wait to arrive at their destination immediately.
The Emperor of the Empire thought the invention was awesome and decided to use the stargate to link each galaxy that he ruled.
It can prove that the construction of N-1 worms can link the N galaxy.
Now the question comes, the emperor wants to know how many construction schemes can link the N galaxy with a N-1 worm hole?
-
Input
-
Enter an integer T in the first line, indicating the number of test data groups (T <= 100)
Each group of test data has only one row, and the row has only one integer N, indicating that there are N galaxies. (2 <= N <= 1000000)
-
Output
-
An integer is output for each group of test data, indicating the number of solutions that meet the question. The output result may be very large. Please output the result after the number of construction schemes is 10003.
-
Sample Input
-
234
-
Sample output
-
316
Pr ü fer coding and the formula of the Cayley
01.
#include
02.
using
namespace
std;
03.
int
main()
04.
{
05.
int
n;
06.
cin>>n;
07.
while
(n--)
08.
{
09.
int
m,s=1;
10.
cin>>m;
11.
for
(
int
i=0;i 12.
s*=m,s%=10003;
13.
cout< 14.
}
15.
return
0;
16.
}