http://acm.hdu.edu.cn/showproblem.php?pid=6144

解法:一个简单的模拟

 #include <bits/stdc++.h>
using namespace std;
int t;
int mod=1e9+;
string s;
int main(){
cin>>t;
while(t--){
int flag=;
long long sum=;
cin>>s;
int len=s.length();
for(int i=;i<len;i++){
if(s[i]=='('){
flag=;
}
}
if(flag==){
for(int i=;i<len;i++){
sum%=mod;
sum*=;
sum+=s[i]-'';
sum%=mod;
}
cout<<sum%mod<<endl;
}else{
string s1="";
string s2="";
s+='(';
int y=;
int st=;
if(s[]>=''&&s[]<=''){
while(s[st]!='('){
s2+=s[st];
st++;
}
}
for(int i=st;i<len;){
if(s[i]=='('){
s1="";
i++;
while(s[i]!=')'){
s1+=s[i];
i++;
}
i++;
}
if(s[i]=='#'){
i+=;
y=;
while(s[i]!=')'){
y*=;
y+=s[i]-'';
y%=mod;
i++;
}
i++;
for(int j=;j<=y;j++){
s2+=s1;
}
if(s[i]>=''&&s[i]<=''){
while(s[i]!='('){
s2+=s[i];
i++;
}
}
}
}
long long ans=;
int Len=s2.length();
for(int i=;i<Len;i++){
ans*=;
ans%=mod;
ans+=s2[i]-'';
ans%=mod;
}
cout<<ans%mod<<endl;
}
}
return ;
}
/*
10
1(1)#(1)
11
1(1)#(1)11
1111
1(1)#(1)101
11101
1(1)#(1)1000
111000
01(1)#(1)1000
111000
*/

2017百度之星程序设计大赛 - 复赛 Arithmetic of Bomb的更多相关文章

  1. 2017"百度之星"程序设计大赛 - 复赛1001&&HDU 6144 Arithmetic of Bomb【java大模拟】

    Arithmetic of Bomb Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  2. 2017"百度之星"程序设计大赛 - 复赛 01,03,05

    Arithmetic of Bomb Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  3. 2017"百度之星"程序设计大赛 - 复赛1005&&HDU 6148 Valley Numer【数位dp】

    Valley Numer Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  4. 2017"百度之星"程序设计大赛 - 复赛1003&&HDU 6146 Pokémon GO【数学,递推,dp】

    Pokémon GO Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  5. [SinGuLaRiTy] 2017 百度之星程序设计大赛 复赛

    [SinGuLaRiTy-1038] Copyright (c) SinGuLaRiTy 2017. All Rights Reserved. Arithmetic of Bomb Problem D ...

  6. 2017"百度之星"程序设计大赛 - 复赛

    Arithmetic of Bomb  Accepts: 1050  Submissions: 1762  Time Limit: 2000/1000 MS (Java/Others)  Memory ...

  7. 【2017"百度之星"程序设计大赛 - 复赛】Arithmetic of Bomb

    [链接]http://bestcoder.hdu.edu.cn/contests/contest_showproblem.php?cid=777&pid=1001 [题意] 在这里写 [题解] ...

  8. 【2017百度之星程序设计大赛 - 复赛】Valley Numer

    [链接]http://acm.hdu.edu.cn/showproblem.php?pid=6148 [题意] 在这里写题意 [题解] 先把1..N里面的山峰数字个数算出来->x 然后用N减去这 ...

  9. HDU 6118 度度熊的交易计划 【最小费用最大流】 (2017"百度之星"程序设计大赛 - 初赛(B))

    度度熊的交易计划 Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total S ...

随机推荐

  1. python关于文件路径和文件名的操作

    os.path.abspath(path) #返回绝对路径(包含文件名的全路径) os.path.basename(path) —— 去掉目录路径获取文件名 os.path.dirname(path) ...

  2. the art of seo(chapter eight)

    How Social Media and User Data Play a Role in Search Results and Rankings ***Correlation Between Soc ...

  3. centos7在VMware下配置网络连接

    安装成功以后,首先更改vmwar的虚拟网络设置 1.参考连接:http://www.cnblogs.com/liongis/p/3265458.html 2.然后将虚拟机的设置里面将网络配置的连接方式 ...

  4. PHPexcel把数据库数据直接转化为excel表格

    运行文件  index.php <?php$dir =dirname(__FILE__); //获取当前文件的路径require $dir.'/Classes/phpexcel.php'; // ...

  5. android自定义控件(五) 自定义组合控件

    转自http://www.cnblogs.com/hdjjun/archive/2011/10/12/2209467.html 代码为自己编写 目标:实现textview和ImageButton组合, ...

  6. poj1821 Fence(单调队列优化dp)

    地址 一排N个木板,M个工匠站在不同位置$S_i$,每个人可以粉刷覆盖他位置的.最长长度为$L_i$木板段,每刷一个有$P_i$报酬.同一木板只刷一次.求最大报酬. 根据每个人的位置dp,设$f[i] ...

  7. ACM学习历程——HDU4472 Count(数学递推) (12年长春区域赛)

    Description Prof. Tigris is the head of an archaeological team who is currently in charge of an exca ...

  8. windows下vs2012用gsoap开发webservice实例

    零:说明 1.本文是根据网上前人经验结合自己动手操作写成,开发工具用的vs2012,gsoap用的是gsoap-2.8: 2.gsoap提供的工具简单介绍 1)wsdl2h.exe:根据WSDL文件生 ...

  9. Android HAL层与Linux Kernel层驱动开发简介

    近日稍微对Android中的驱动开发做了一些简要的了解. HAL:Hardware Abstract Layer 硬件抽象层,由于Linux Kernel需要遵循GPL开源协议,硬件厂商为了保护自己硬 ...

  10. layout属性

    RelativeLayout 第一类:属性值为true可false android:layout_centerHrizontal        水平居中 android:layout_centerVe ...