HDU ACM 2200 Eddy ' s AC puzzle

Source: Internet
Author: User

Analytical:

1, can choose M individual (n=>m>=2), there is CN (m) in the selection;
2, and then the M-Personal divided into 2 groups (everyone to group), to meet the minimum AC number is greater than the maximum AC number, only need to be inserted in the M-person board can be;

For example:
M-Individuals if the distinction is:
1,2,3,4,......m-1,m (M personal AC number arranged from small to large)
The board can be divided into 2 groups that meet the requirements in any position:
1,2,3......T, | | T+1...m-1,m (1<=T<M)
The 1,2,3......t is a set of
T+1,t+2,......m-1,m as a group

3, note cn (m) =n!/(m!* (n-m)!) = (n (n-1) * (n-2) *...* (n-m+1))/(1*2*3*...*M).


#include <iostream> using namespace Std;__int64 getcnm (__int64 n,__int64 m) {__int64 s,i;for (s=1,i=1;i<=m;i++)    //CN (M) s=s* (n-i+1)/i;return s;} int main () {__int64 res,n,i;while (scanf ("%i64d", &n)!=eof) {res=0;for (i=2;i<=n;i++) res+= (i-1) *GETCNM (n,i); printf ("%i64d\n", res);}    return 0;}


HDU ACM 2200 Eddy ' s AC puzzle

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.