How many pieces of land?

这道题目的算法是c(n,4)+c(n,2)+1=(n^4-6*n^3+23*n^2-18*n+24)/24, 如何得出的,我还没有证明出来,如有人知道,可访赐教。谢谢。

// How Many Pieces of Land.cpp : Defines the entry point for the console application. // #include "stdafx.h" using namespace std; int _tmain(int argc, _TCHAR* argv[]) { int expdata(int n,int a ); int testround=0; cin>>testround; while(testround--) { if(testround<0)break; else { int point=0; cin>>point; int result=(expdata(point,4)-expdata(point,3)*6+23*expdata(point,2)-18*point+24)/24; cout<<result<<"/n"; } } return 0; } int expdata(int n,int a) { int b=1; while(a--) { if(a<0)break; else b=b*n; } return b; }  

你可能感兴趣的:(c,算法)