记录编号 |
47162 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[NOIP 2010冲刺十三]外星密码 |
最终得分 |
100 |
用户昵称 |
怡红公子 |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.003 s |
提交时间 |
2012-10-30 23:20:38 |
内存使用 |
3.28 MiB |
显示代码纯文本
- #include<iostream>
- #include<cstring>
- #include<fstream>
- using namespace std;
- ifstream fin("passworda.in");
- ofstream fout("passworda.out");
-
- string Work(string s,int l,int r){
- if(l>r) return "";
- int suml=0,sumr=0,i,tot=0;
- string ans="";string s1="",s2="";
-
- while(s[l]<='9'&&s[l]>='0') tot=tot*10+s[l]-'0',l++;if(tot==0) tot=1;
- if(s[l]<='Z'&&s[l]>='A')
- {
- while(s[l]<='Z'&&s[l]>='A') s1+=s[l],l++;
- if(l>r) {for(i=1;i<=tot;++i) ans+=s1; return ans;}
- }
-
- for(i=l;i<=r;++i) {if(s[i]=='[') suml++;else if(s[i]==']') sumr++;if(suml==sumr) break;}
- s1+=Work(s,l+1,i-1);s2=Work(s,i+1,r);
-
- for(int i=1;i<=tot;++i) ans+=s1+s2;
- return ans;
- }
-
- int main()
- {
- string s;
- fin>>s;
- s="1["+s+"]";
- string ans="";
- ans=Work(s,0,s.size()-1);
-
- fout<<ans<<endl;
- // system("pause");
- return 0;
-
- }