Skip to content

Instantly share code, notes, and snippets.

@mi6112ogit
Created September 15, 2017 06:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mi6112ogit/43f11673ba894460accdc05e188ceee3 to your computer and use it in GitHub Desktop.
Save mi6112ogit/43f11673ba894460accdc05e188ceee3 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <algorithm>
#include <utility>
#include <map>
#include <queue>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
using namespace std;
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF (1 << 30)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> Pi;
const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
int num[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int n, sum;
int latte[10][10];
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
scanf("%d %d", &n, &sum);
do{
rep(i, n) latte[0][i] = num[i];
FOR(i, 1, n) rep(j, n - i) {
latte[i][j] = latte[i - 1][j] + latte[i - 1][j + 1];
}
if(latte[n - 1][0] == sum) {
rep(i, n) {
printf("%d", num[i]);
(i == n - 1) ? printf("\n") : printf(" ");
}
return 0;
}
}while(next_permutation(num, num + n));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment