/*input ()()()(()) */ #include <bits×dc++.h> using namespace std; typedef long long ll; inline ll read() { char c = getchar(); ll x = 0, f = 1; while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();} while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar(); return x * f; } const int inf=0x3f3f3f3f; const int maxn=1e5+50; const ll mod=1e9+7; int main(){ string s; cin>>s; int len=s.length(); stack<int> sta; for(int i=0;i<len;i++){ if(s[i]=='('){ sta.push(-1); sta.push(1); } else{ ll cur=1; while(sta.size()&&sta.top()!=-1){ cur=cur*sta.top()%mod; sta.pop(); } sta.pop(); sta.push(cur+1); } } ll cur=1; while(sta.size()&&sta.top()!=-1){ cur=cur*sta.top()%mod; sta.pop(); } cout<<cur<<endl; return 0; }
1 1

相关推荐

05-15 16:48
上海大学 Java
忙碌的芝士选钝角:招侦探?
点赞 评论 收藏
分享
牛客网
牛客企业服务