Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using namespace std;
- typedef long long ll;
- int counter = 0;
- int finder = 45;
- vector<char> ans;
- void solve(int n, int counter){
- if(n == 0 && counter == finder){
- for(int i = 0; i < ans.size(); ++i){
- cout << ans[i] << " ";
- }
- }else{
- ans.push_back('+');
- solve(n - 1, counter + n);
- ans.pop_back();
- ans.push_back('-');
- solve(n - 1, counter - n);
- ans.pop_back();
- }
- }
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(0);
- cout.tie(0);
- solve(9, 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement