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.
Outputs description Output Description
The number of possibilities to mount the error.
Sample input to sample
Input Example 1
2
Input Example 2
4
Sample output Sample Outputs
Output Example 1
1
Output Example 2
9
Data Size & Hint
1≤n≤100
/*recursion + high precision. The first time got 60 points, the B, C array to the main function outside it is over, long memory ... There are n letters, the first letter is loaded wrong words have i-1 kind of possibility, set i-1 one is K, then K has two kinds of loading method: ①: Into the first envelope, at this time the remaining I-2 letter to be installed in i-2 envelope, there is f[i-2]; ②: Loaded into an envelope other than I, then the i-1 function and I, the rest of the f[i-1]; To sum up, get the state transfer equation: f[i]= (i-1) * (F[i-1]+f[i-2])*/#include<cstdio>#include<iostream>#include<cstring>#defineM 210using namespacestd;structnode{intA[m],len;}; Node F[m];intB[m],c[m];intMain () {intN; scanf ("%d",&N); f[1].a[1]=0; f[2].a[1]=1; f[1].len=1; f[2].len=1; for(intI=3; i<=n;i++) { //High-precision addition intlena=f[i-1].len,lenb=f[i-2].len,lenc=1, x=0; while(lenc<=lena| | lenc<=LenB) {F[i].a[lenc]=f[i-1].a[lenc]+f[i-2].a[lenc]+x; X=f[i].a[lenc]/Ten; F[I].A[LENC]%=Ten; Lenc++; } F[i].a[lenc]=Y; if(f[i].a[lenc]==0) lenc--; F[i].len=Lenc; //high-precision multiplication intla=f[i].len,zh=i-1, lb=0; memset (b,0,sizeof(b)); Memset (c,0,sizeof(c)); while(ZH) {b[++lb]=zh%Ten; ZH/=Ten; } for(intj=1; j<=la;j++) { intx=0; for(intk=1; k<=lb;k++) {c[j+k-1]+=f[i].a[j]*b[k]+x; X=c[j+k-1]/Ten; C[j+k-1]%=Ten; } c[j+lb]=x; } intlc=la+lb; F[i].len=LC; while(c[lc]==0&&lc>1) lc--; for(intj=lc;j>=1; j--) F[i].a[j]=C[j]; } intflag=0; for(inti=f[n].len;i>=1; i--) if(!flag&&!f[n].a[i])Continue; Else{printf ("%d", F[n].a[i]); Flag=1; } return 0;}
View Code
⑨ to write (Codevs 1697)