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