Title Description
Description
Qi Cirno (Ice Goblin) has the ability to control the air-conditioning. It is more dangerous to freeze a small thing in an instant than a normal goblin. had been releasing the air-conditioner around her always very cold.
Due to the following three points reason ...
- Qi Cirno's Fuca symbol "Icicle Fall"-easy of the bomb screen is enough stupid, as long as standing in front of her there is no play will touch you;
- Zun in "Red Devil Township" introduced her when she said she was a bit stupid;
- In the Zun release "Oriental Phantasmagoria Tomb" Introduction map, in the picture put the Qi Lulu in the position of ⑨, and with "⑨ idiot" simple take, from "⑨" and "idiot" became her alias ...
So Kiki Cirno got the nickname of "idiot".
One day, Kiki Cirno again 2 ...
She wrote n letters to be loaded into N envelopes, but all were wrong ... Now you want to know how many kinds of possibilities are wrong.
Enter a description
Input Description
Number of letters and envelopes N.
Output description
Output Description
The number of possibilities to mount the error.
The category label says it's a serial DP, and it feels like this is a combinatorial math mismatch problem.
A total of n elements, with a number of DN
D2=1; d3=2;
Assuming that N is ranked K, K has (n-1) species may
If k is in the position of N, the remaining Dn-2 species may
If k is not in the position of N, then the nth bit is reconsidered as a new "K-bit", when the number of remaining n-1, including K, is equivalent to the wrong row of only the number of n-1 (only the K-bit will be replaced by the nth bit). The number of rows is Dn-1.
So, dn= (n-1) * (dn-1+dn-2)
High-precision Operation
var num1,num2,num:array[1..10000]of integer;
N:longint;
I,j,k,len:longint;
Begin READLN (n);
Num1[1]:=1;
num2[1]:=2;
Len:=1;
For j:=4 to N do
Begin for I:=1 to Len do
Num[i]:=num1[i]+num2[i];
For I:=1 to Len do
Begin Num[i+1]:=num[i+1]+num[i] DIV 10;
Num[i]:=num[i] MoD 10;
End
If num[len+1]<>0
Then Inc (LEN);
For I:=1 to Len do
num[i]:=num[i]* (j-1);
For I:=1 to Len do
Begin Num[i+1]:=num[i+1]+num[i]div 10;
Num[i]:=num[i] MoD 10;
End
While num[len+1]<>0 do
Inc (LEN);
num1:=num2;
Num2:=num;
End
For I:=len Downto 1 do
Write (Num[i]);
End.
Sequence type Dp:⑨ to write a letter