Advertisement
leminhkt

69

Jul 21st, 2020
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4.  
  5. int main(){
  6.     int n, s; cin >> n >> s;
  7.     s = s + n*(n + 1)/2 - 2;
  8.  
  9.  
  10.     vector<int> a(n - 1);
  11.     for(int i = n; i >= 2 && s; i--)
  12.         if(2*i == s || 2*i <= s - 4)
  13.             s -= 2*i,
  14.             a[i - 2] = 1;
  15.  
  16.  
  17.     if(s) return cout << "Impossible", 0;
  18.     cout << 1;
  19.     for(int i = 0; i <= n - 2; i++)
  20.         cout << "-+"[a[i]] << i + 2;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement