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 ...
随机推荐
- codeforces 613A. Peter and Snow Blower
题目链接 给一个多边形, 一个多边形外的定点, 求这个点距离多边形的最短距离和最长距离. 最长距离肯定是和某个顶点的连线, 而最短距离是和点的连线或是和某条边的连线. 对于一条边上的两个点a, b, ...
- (Problem 42)Coded triangle numbers
The nth term of the sequence of triangle numbers is given by, tn = ½n(n+1); so the first ten triangl ...
- 编写EL函数
1.建立java类的静态函数 package chapter4; public class ELFun { public static String processStr(String s){ s = ...
- JavaEE Tutorials (11) - 使用Criteria API创建查询
11.1Criteria和Metamodel API概述16811.2使用Metamodel API为实体类建模170 11.2.1使用元模型类17011.3使用Criteria API和Metamo ...
- hdoj 1166 敌兵布阵(树状数组)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1166 思路分析:该问题为动态连续和查询问题,使用数组数组可以解决:也可使用线段树解决该问题: 代码如下 ...
- HDU 3032 Nim or not Nim? (sg函数求解)
Nim or not Nim? Problem Description Nim is a two-player mathematic game of strategy in which players ...
- STL之queue(单向队列)
单向队列中的数据是先进先出(First In First Out,FIFO).单向队列一共6个常用函数(front().back().push().pop().empty().size()) #inc ...
- Dapper 多数据库优化
Dapper是近2年异军突起的新ORM工具,它有ado.net般的高性能又有反射映射实体的灵活性,非常适合喜欢原生sql的程序员使用,而且它源码很小,十分轻便.我写本博客的目的不是为了介绍Dapper ...
- [LeetCode]题解(python):011-Container With Most Water
题目来源: https://leetcode.com/problems/container-with-most-water/ 题意分析: 给出一个n长度的非0数组,a1,a2,……,an,ai代表在坐 ...
- vagrant 入门4
7. 打包 Packaging , 8080 end 2. 打包Project $ vagrant package --vagrantfile Vagrantfile.pkg 8. 打包完成后,在工程 ...