题解 | #小欧的括号嵌套#

小欧的括号嵌套

https://www.nowcoder.com/practice/0b461d2b82834cb1881567744effb0c1

#include<bits/stdc++.h>
using namespace std;
//先处理r,在处理n
int main() {
    int n,r;
    cin>>n>>r;
    for(int i=0;i<r;i++){
        cout<<'(';
    }
    for(int i=0;i<r;i++){
        cout<<')';
    }
    for(int i=0;i<2*(n-r);i++){
        if(i&1){
            cout<<')';
        }else{
            cout<<'(';
        }
    }
}

全部评论

相关推荐

牛客60022193...:大厂都招前端,他们觉得AI能替代前端,可能他们公司吊打btaj吧
点赞 评论 收藏
分享
评论
4
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务