Hangzhou electric 2048--God, God, and heaven

Source: Internet
Author: User

God, God, and the heavens.

Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 26867 Accepted Submission (s): 11176


Problem DESCRIPTIONHDU 2006 ' ACM Contest Awards Gala Grand start!
In order to enliven the atmosphere, organizers held a special, prize-rich lottery, the specific requirements of this activity is:

First, all participants in the party put a note with their name in the lottery box;
Then, after all the notes are added, each person takes a note from the box;
Finally, if the note is written on its own name, then "Congratulations, the jackpot!" ”

You can imagine the atmosphere at that time, after all, the winner of the prize is everyone's dream twins signature photo! However, just as all the comedy attempts to design often end in tragedy, no one has won the lottery in the end!

My God, God, and the heavens, how could this be?

But let's not get excited, now that's the problem, can you calculate the probability of this happening?

Not counting? Do you also want to end with a tragedy?!

The first line of input data is an integer c, representing the number of test instances, followed by the C row of data, each line containing an integer n (1<n<=20), representing the number of participants in the lottery.

Output for each test instance, export the percentage that this occurs, the output of each instance is a row, and the result retains two decimal places (rounded), in the exact format, refer to sample output.

Sample Input
1 2

Sample Output
50.00%

AUTHORLCY////According to the test instructions, the total number of n=, c= the result of the wrong formula, d=n the whole arrangement; results =c/d;  The problem has a regular, can be obtained, if (n<7) results =c/d; Else results =c (7)/d (7); N==0 also to be considered;
1#include <stdio.h>2 intbiao[ One],sieve[ One];3 intMain ()4 {5     intI,n,total=1; sieve[1]=0; sieve[2]=1;6      for(i=1;i< One; i++)7     {8Total*=i; biao[i]=Total ;9         if(i>=3)Tensieve[i]= (I-1) * (sieve[i-1]+sieve[i-2]); One     } Ascanf"%d",&i); -      while(i--) -     { thescanf"%d",&n); -         if(n==0) -printf"0.00%c\n",'%'); -         Else if(n>=1&&n<=6) +printf"%.2lf%c\n", sieve[n]*100.0/biao[n],'%'); -         Else +printf"%.2lf%c\n", sieve[7]*100.0/biao[7],'%'); A     } at     return 0; -}

__int64! (But the problem is regular, not used);

 

Hangzhou electric 2048--God, God, and heaven

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.