标签:des style blog color os io strong 数据
思路:假如说有N个数,从中取M个 是Cnm,
而M个数要满足条件只要从1-M排列插板即可。
1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 #include <string> 5 #include <iomanip> 6 #include <algorithm> 7 #include <queue> 8 #include <vector> 9 #include <map> 10 using namespace std; 11 long long cal(long long n, long long x){ 12 long long sum = 1; 13 for(int i = 1; i <= x; i++){ 14 sum = sum*(n-i+1)/i; 15 } 16 return sum; 17 } 18 int main(){ 19 long long N, sum; 20 while(cin>>N){ 21 sum = 0; 22 for(long long i = 2; i <= N; i++){ 23 sum += (i-1)*cal(N, i); 24 } 25 cout<<sum<<endl; 26 } 27 return 0; 28 }
hdu 2200 Eddy's AC难题,布布扣,bubuko.com
标签:des style blog color os io strong 数据
原文地址:http://www.cnblogs.com/titicia/p/3906131.html