HDU6144 Arithmetic of Bomb
来源:互联网 发布:欧碧诗胶原蛋白知乎 编辑:程序博客网 时间:2024/06/16 05:34
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6144
字符串的展开+大数取模
由于不存在括号套括号的鬼畜神奇情况,所以直接模拟即可
附大数取模:
len:=length(ss); ans:=0; for i:=1 to len do ans:=(int64(ans)*10+ord(ss[i])-48)mod tt;
贴代码
const tt=1000000007; var s,ss,cc,bb:ansistring; top,Q,i,t,len,bo,num,j,kk,k1,ans:longint; a:array[0..10005]of ansistring; begin// assign(input,'6144.in');reset(input);// assign(output,'6144.out');rewrite(output); readln(Q); top:=0; for t:=1 to Q do begin readln(s);bo:=0; if s='' then begin writeln(0); continue; end; ss:=''; kk:=0; i:=1;len:=length(s); while i<=len do begin if s[i] in ['0'..'9'] then begin num:=0; k1:=0;j:=i; while (j<=len)and(s[j] in['0'..'9'])do inc(j); inc(top);a[top]:=copy(s,i,j-i); i:=j; if bo=1 then begin val(a[top],num);dec(top);for j:=1 to num do ss:=ss+a[top];dec(top);end else if (i>len)or(s[i]='(')then begin ss:=ss+a[top];dec(top);end; bo:=0; end else if s[i]='#' then begin inc(i);bo:=1;end else inc(i); end; fillchar(a,sizeof(a),0); len:=length(ss); ans:=0; for i:=1 to len do ans:=(int64(ans)*10+ord(ss[i])-48)mod tt; writeln(ans); end;// close(input);close(output); end.
【写的有漏洞的,欢迎路过大神吐槽】
2017/08/24 18:29:27
Ending.
阅读全文
1 0
- HDU6144-Arithmetic of Bomb
- HDU6144 Arithmetic of Bomb
- 【字符串处理】HDU6144 Arithmetic of Bomb
- Hdu6144 Arithmetic of Bomb(2017百度之星程序设计大赛
- HDU6144 Arithmetic of Bomb (2017百度之星程序设计大赛
- HDU 6144:Arithmetic of Bomb
- HDU 6144 Arithmetic of Bomb(模拟)
- Hdu 6144 Arithmetic of Bomb 模拟
- 2017百度之星复赛1001 Arithmetic of Bomb
- 2017百度之星复赛1001 Arithmetic of Bomb
- 百度之星复赛--Arithmetic of Bomb----暴力
- HDU-2017"百度之星"程序设计大赛-复赛-1001-Arithmetic of Bomb
- HDU 6144 Arithmetic of Bomb(字符串+大数取余模板)
- HDU 6145 Arithmetic of Bomb II(数学+矩阵快速幂)
- HDU 6145 Arithmetic of Bomb II or Aizu 2789 Compressed Formula 表达式展开求值 矩阵快速幂
- Bomb
- Bomb
- Bomb
- this指针的理解
- Universal 2nd Factor (U2F) 概述(2)-背景
- 初始化方法
- 【词汇详解】HTTP的几个重要概念
- Iframe跨域访问
- HDU6144 Arithmetic of Bomb
- 关于流通系统的流失特性的研究
- BZOJ 4800 [Ceoi2015]Ice Hockey World Championship ……
- Java-mysql-批量插入
- 【PAT】【Advanced Level】1072. Gas Station (30)
- js闭包(closure)
- Redis为什么是单线程
- Eclipse自动补全功能轻松设置
- MyBatis 详细介绍