Problem:
Recursion, but a[i]= (A[i-1]+a[i-2]) + (I-1) formula is not rolled out.
When recursive, the FOR loop constraint value with the input m causes the array to have no storage number.
I and J are mixed in for loops when calculating the factorial, resulting in no number output.
Rounding takes n bits: double l=1315.1354 String s=string.format ("%.2f", l); syso s;
God, God, and the heavens.Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 26688 Accepted Submission (s): 11107
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
12
Sample Output
50%
Import java.util.*;p ublic class main{public static void Main (string[] args) {Scanner cin=new Scanner (system.in); int n=cin . Nextint (); for (int. i=0;i<n;i++) {double a[]=new double[25];d ouble l,c=1;int m=cin.nextint (); for (int j=4;j<=23;j + +) {a[2]=1;a[3]=2;a[j]= (j-1) * (A[j-1]+a[j-2]);} for (int j=2;j<=m;j++) {c*=j;} l=a[m]/c*100; String S=string.format ("%.2f", L); s=s+ "%"; System.out.println (s);}}}
Hdu God, God, and the heavens. Java