思路:简单的递归。
代码:
#includeusing namespace std;#define ll long long#define pb push_back#define mem(a,b) memset(a,b,sizeof(a))void c(ll n,ll k){ ios::sync_with_stdio(false); cin.tie(0); if(n==0)return ; if(k>=n-1) { cout<<'('; c(n-1,k-(n-1)); cout<<')'; } else { cout<<"()"; c(n-1,k); }}int main(){ ios::sync_with_stdio(false); cin.tie(0); ll n,k; cin>>n>>k; if(n*(n-1)/2 <<"Impossible"; else c(n,k); cout<