HDU 3625 Examining the Rooms
Test instructions
Very difficult to describe
Ideas:
The first class of Stirling numbers, in fact, is the enumeration of room 1 and the rest of the room tied together in the case (n-1) *sigma (I=1~k,sti[n-1][i]).
/*hdu 3625 Examining the Rooms test instructions: very difficult to describe the idea: The first kind of Stirling number, in fact, the molecule is enumerating room 1 and the rest of the room tied together, for (n-1) *sigma (I=1~k, Sti[n-1][i]). */#include <iostream> #include <cstdio>using namespace std; #define LL __int64ll sti[25][25];void Get_sti ( int n) {for (int i=1;i<=n;++i) {sti[i][0]=0;sti[i][i]=1;} for (int i=2;i<=n;++i) {for (int j=1;j<i;++j) {sti[i][j]= (i-1) *sti[i-1][j]+sti[i-1][j-1];}}} void print (int n) {LL sum;for (int i=1;i<=n;++i) {sum=0;for (int j=0;j<=i;++j) {cout<<sti[i][j]<< '; SUM+=STI[I][J];} Cout<<endl;//cout<<sum<<endl;}} int main () {get_sti (//print); int n,k;int t;scanf ("%d", &t), while (t--) {scanf ("%d%d", &n,&k);d ouble fz=0.0,fm=0.0;for (int i=0;i<=k;++i) {fz+= (double) sti[n-1][i];} for (int i=0;i<=n;++i) {fm+= (double) sti[n][i];} cout<<fz<< ' <<fm<<endl;printf ("%.4f\n", fz* (n-1)/fm);} return 0;}
HDU 3625 Examining the Rooms