NYOJ-127 Stargate (1)

Source: Internet
Author: User

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. }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.