您的位置:首页 > 运维架构

topcoder SRM 592 DIV2 LittleElephantAndPermutationDiv2

2013-10-19 22:18 579 查看
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#define LL long long

using namespace std;

class LittleElephantAndPermutationDiv2{
public:
LL getNumber(int N, int k){
LL res = 0;
vector<int> a(N);
for(int  i = 0 ; i < N;  ++ i ){
a[i] = i + 1;
}
do{
LL value = 0;
for(int i = 0; i < N; ++ i){
value += max(a[i],i+1);
}
if( value >= k )  ++res;
copy(a.begin(),a.end(),ostream_iterator<int>(cout," "));
cout<<endl;
}while(next_permutation(a.begin(),a.end()));
cout<<res<<endl;
for(int  i = 1; i<= N; ++ i) res *= i;
return res;
}
};
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: