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; } };
相关文章推荐
- topcoder SRM 592 DIV2 LittleElephantAndBooks
- Topcoder SRM 597 LittleElephantAndSubset
- Codeforces Round #136 (Div. 2) D. Little Elephant and Array 线段树 离线处理
- Codeforces Round #129 (Div. 1)B Little Elephant and Cards
- Codeforces Round #157 (Div. 2) D. Little Elephant and Elections(数位DP+枚举)
- Codeforces Round #129 (Div. 2)A. Little Elephant and Rozdil
- Codeforces Round #136 (Div. 2) D. Little Elephant and Array
- codeforces 204(Div.1 A) Little Elephant and Interval(贪心)
- Codeforces Round #129 (Div. 1)B Little Elephant and Cards
- topcoder SRM 623 DIV2 CatAndRat
- Codeforces Round #129 (Div. 2) B. Little Elephant and Sorting
- Codeforces Round #157 (Div. 1)---A. Little Elephant and Bits
- Codeforces Round #129 (Div. 1)E. Little Elephant and Strings
- Topcoder SRM 561 DIV2 1000 FoxAndTouristFamilies
- Codeforces Round #129 (Div. 1) A Little Elephant and Interval
- Codeforces Round #136 (Div. 2) Little Elephant and Array
- Codeforces Round #157 (Div. 2) A. Little Elephant and Chess
- [Codeforces Round #157 (Div. 2)]A. Little Elephant and Chess
- Codeforces Round #129 (Div. 1) B. Little Elephant and Cards
- SRM 595 D2 L3:LittleElephantAndXor, dp