HDU 3625 Examining the Rooms

Source: Internet
Author: User

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

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.