HDU 4891
一道简单的模拟题
需要要匹配{} 和 $$ 符里面的东西即可
//#pragma comment(linker, "/STACK:16777216") //for c++ Compiler
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#define ll long long
#define Max(a,b) (((a) > (b)) ? (a) : (b))
#define Min(a,b) (((a) < (b)) ? (a) : (b))
#define Abs(x) (((x) > 0) ? (x) : (-(x)))
using namespace std; const int INF = 0x3f3f3f3f; char a[];
ll flag1, flag2;
ll flag1_num, flag2_num;
ll ans;
bool ff; void init(){
flag1 = flag2 = ;
flag1_num = flag2_num = ans = ;
ff = false;
} int main(){
ll i, j, k, t, m, n;
while(cin >> n){
getchar();
init();
for(k = ; k < n; ++k){
gets(a);
ll len = strlen(a);
for(i = ; i < len; ++i){
if(a[i] == '{'){
flag1 = ;
} else if(a[i] == '}'){
flag1 = ;
ans *= flag1_num;
flag1_num = ;
} else if(a[i] == '$' && !flag2){
flag2 = ;
} else if(a[i] == '$' && flag2){
flag2 = ;
} else if(a[i] == '|' && flag1){
++flag1_num;
} else if(a[i] == ' ' && flag2){
++flag2_num;
} else{
flag2_num = ;
} if(a[i] == ' ' && a[i + ] != ' ' && flag2){
ans *= flag2_num;
flag2_num = ;
}
if(ans > ) ff = true;
}
}
if(ff){
printf("doge\n");
}
else{
cout << ans << endl;
}
}
return ;
}
HDU 4891的更多相关文章
- 2014联合三所学校 (HDU 4888 HDU 4891 HDU 4893)
HDU 4891 The Great Pan 注册标题 他怎么说,你怎么样 需要注意的是乘法时,它会爆炸int 代码: #include<iostream> #include<c ...
- HDU 4891 The Great Pan (字符串处理)
题目链接:HDU 4891 The Great Pan 求一串字符有多少种不同的意思,当中关心'{','}'之间的'|'. 和'$','$'之间的空格,连续N个空格算N+1种. AC代码: #incl ...
- hdu 4891 模拟水题
http://acm.hdu.edu.cn/showproblem.php?pid=4891 给出一个文本,问说有多少种理解方式. 1. $$中间的,(s1+1) * (s2+1) * ...*(sn ...
- 2014多校第三场1005 || HDU 4891 The Great Pan(模拟)
题目链接 题意 : 给你n行字符串,问你有多少种理解方式.有两大类的理解 (1){A|B|C|D|...}代表着理解方式可以是A,可以是B或C或者D. (2)$blah blah$,在$$这两个符号中 ...
- HDU 4891 The Great Pan (模拟)
The Great Pan 题目链接: http://acm.hust.edu.cn/vjudge/contest/123554#problem/D Description As a programm ...
- HDU 4891 The Great Pan
模拟题. #include<map> #include<set> #include<ctime> #include<cmath> #include< ...
- HDU 4891 The Great Pan (题意题+模拟)
题意:给定一个文章,问你有多少种读法,计算方法有两种,如果在$中,如果有多个空格就算n+1,如果是一个就算2的次方,如果在{}中, 那么就是把每个空格数乘起来. 析:直接模拟,每次计算一行,注意上一行 ...
- hdu 4891 模拟
题意: 给你一个串,问你有几种意思,有两个规则 (1) { } 答案乘以 ({}之间"|"的个数 + 1) (2) && 答案乘以 (&a ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
随机推荐
- java从c struct传来的字节数组中取值
public int getInt(byte[] array,int index) { return (array[index] & 0xff) | (array[index + 1] & ...
- 用javascirpt画个太极
偶然看到用代码画太极,感觉很有趣,用JS写了一个 过程很简单,画了张图,应该一看就懂了 代码也很简单,如下,注释很多 function TaiJi(r,canvas){ this.r = r; thi ...
- Understanding and Selecting a SIEM/LM: Correlation and Alerting
Continuing our discussion of core SIEM and Log Management technology, we now move into event correla ...
- Protel99se生成gerber文件的方法
这几天工作中遇到制作 gerber 的问题,确实让我郁闷了一 番,为了方便大家,不要再受其苦,特将这一过程写成文档供有这方面需要的同仁们参考. 1 protel99se 打开要生成 gerber 的 ...
- Oracle 使用RMAN
RMAN 数据库备份 特点: . 跳过未使用的数据块 . 备份压缩 . 执行增量备份 . 块级别的恢复 组件: . RMAN命令执行器(RMAN Executable) . 目标数据库(Traget ...
- Mysql 创建联合主键
Mysql 创建联合主键2008年01月11日 星期五 下午 5:21使用primary key (fieldlist) 比如: create table mytable ( ...
- iOS键盘遮挡问题解决办法
iOS开发之“键盘遮挡输入框的解决办法”之一 -----键盘通知之前处理这种问题,总是在触发输入框编辑事件键盘弹出的时候,将当前的View整体向上移动,结束编辑又整体向下移,耗时耗力效率低. 在网上看 ...
- IPv4头部结构具体解释
IPv4头部结构具体解释 下面为书中原文摘录: $(function () { $('pre.prettyprint code').each(function () { var lines = $(t ...
- 在SQL 中生成JSON数据
这段时间接手一个数据操作记录的功能,刚拿到手上的时候打算用EF做,后来经过仔细考虑最后还是觉定放弃,最后思考再三决定: 1.以模块为单位分表.列固定(其实可以所有的操作记录都放到同一个表,但是考虑到数 ...
- 使CSS3样式在IE里面有效果
1. 下载ie-css3.htc文件 2. 当前元素一定要有定位属性,像是position:relative或是position:absolute属性. 3. z-index值一定要比周围元素的要高 ...