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. static语句块的执行时间

    package utfTest; public class Test01 { public static void main(String[] args) { //Person.show(); Sys ...

  2. struts2的结果类型

    1.从struts-default.xml入手,得到结果类型列表以及对应的处理类: <result-types> <!-- 转发到action --> <result-t ...

  3. Linux 查看并删除.svn目录

    1. find . -type d -name ".svn"|xargs rm -rf

  4. android自定义控件(一) 官方文档的翻译

    构建自定义组件 Android中,你的应用程序程序与View类组件有着一种固定的联系,例如按钮(Button).文本框(TextView),可编辑文本框(EditText),列表框(ListView) ...

  5. MySQL 用户管理与权限管理

    MySQL 用户管理与权限管理 -- 操作环境mysql> show variables like 'version';  +---------------+--------+| Variabl ...

  6. bzoj 3230 相似子串 —— 后缀数组+二分

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3230 先算出每个后缀贡献子串的区间: 然后前缀LCP直接查询,后缀LCP二分长度,查询即可: ...

  7. 杂项:OASIS(结构化信息标准促进组织)

    ylbtech-杂项:OASIS(结构化信息标准促进组织) 1.返回顶部 1. OASIS(结构化信息标准促进组织,Organization for the Advancement of Struct ...

  8. 如何使用Git命令将项目从github或者服务器上克隆下来

    在本地新建一个文件夹,作为本地仓库,如“demo”.单击右键git Bush here,打开git,输入命令: cd /c/Users/Administrator/Desktop/demo  然后按回 ...

  9. SVN服务器搭建教程

    常见的源代码管理工具 CVS 历史悠久,现在几乎没人使用 SVN 集中式版本控制的代表 CVS的接班人,速度比CVS快,功能比CVS强大 在国内使用率非常高(70%~90%) GIT 分布式源代码管理 ...

  10. java&nbsp;Class类

    java Class类 Class类(在java.lang包中,Instances of the class Classrepresent classes and interfaces in a ru ...