题意:给定一个文章,问你有多少种读法,计算方法有两种,如果在$中,如果有多个空格就算n+1,如果是一个就算2的次方,如果在{}中,

那么就是把每个空格数乘起来。

析:直接模拟,每次计算一行,注意上一行最后有空格,下面第一个也是,要全部算上。

代码如下:

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
#define debug puts("+++++")
//#include <tr1/unordered_map>
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std;
//using namespace std :: tr1; typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const LL LNF = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 1e3 + 5;
const LL mod = 1e9 + 7;
const int N = 1e6 + 5;
const int dr[] = {-1, 0, 1, 0, 1, 1, -1, -1};
const int dc[] = {0, 1, 0, -1, 1, -1, 1, -1};
const char *Hex[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
inline LL gcd(LL a, LL b){ return b == 0 ? a : gcd(b, a%b); }
inline int gcd(int a, int b){ return b == 0 ? a : gcd(b, a%b); }
inline int lcm(int a, int b){ return a * b / gcd(a, b); }
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline int Min(int a, int b){ return a < b ? a : b; }
inline int Max(int a, int b){ return a > b ? a : b; }
inline LL Min(LL a, LL b){ return a < b ? a : b; }
inline LL Max(LL a, LL b){ return a > b ? a : b; }
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
}
char s[1000000];
const int ttt = 100000;
int main(){
while(scanf("%d", &n) == 1){
getchar();
LL ans = 1;
bool ok = false;
bool is = false;
int cnt1 = 0, cnt2 = 0;
bool ok1 = false;
bool ok2 = false;
while(n--){
gets(s);
for(int i = 0; s[i]; ++i){
if(s[i] == '$' && !ok1) ok1 = true;
else if(s[i] == '{') ok2 = true;
else if(s[i] == '$'){
ok1 = false;
if(!cnt1) continue;
if(cnt1 == 1){
if(ans * 2LL > ttt) ok = true;
else ans *= 2LL;
}
else {
if(ans * (cnt1+1) > ttt) ok = true;
else ans *= (cnt1 + 1);
}
cnt1 = 0;
}
else if(s[i] == '}'){
ok2 = false;
if(ans * (cnt2+1) > ttt) ok = true;
else ans *= cnt2 + 1;
cnt2 = 0;
}
else if(s[i] == '|' && ok2) ++cnt2;
else if(s[i] == ' ' && ok1) ++cnt1;
else{
if(ok1 && cnt1){
if(cnt1 == 1){
if(ans * 2LL > ttt) ok = true;
else ans *= 2LL;
}
else {
if(ans * (cnt1+1) > ttt) ok = true;
else ans *= (cnt1 + 1);
}
cnt1 = 0;
}
}
}
}
if(ok) puts("doge");
else printf("%I64d\n", ans);
}
return 0;
}

HDU 4891 The Great Pan (题意题+模拟)的更多相关文章

  1. HDU 4891 The Great Pan (字符串处理)

    题目链接:HDU 4891 The Great Pan 求一串字符有多少种不同的意思,当中关心'{','}'之间的'|'. 和'$','$'之间的空格,连续N个空格算N+1种. AC代码: #incl ...

  2. 2014多校第三场1005 || HDU 4891 The Great Pan(模拟)

    题目链接 题意 : 给你n行字符串,问你有多少种理解方式.有两大类的理解 (1){A|B|C|D|...}代表着理解方式可以是A,可以是B或C或者D. (2)$blah blah$,在$$这两个符号中 ...

  3. HDU 4891 The Great Pan (模拟)

    The Great Pan 题目链接: http://acm.hust.edu.cn/vjudge/contest/123554#problem/D Description As a programm ...

  4. HDU 4891 The Great Pan

    模拟题. #include<map> #include<set> #include<ctime> #include<cmath> #include< ...

  5. 2014联合三所学校 (HDU 4888 HDU 4891 HDU 4893)

    HDU 4891 The Great Pan 注册标题  他怎么说,你怎么样  需要注意的是乘法时,它会爆炸int 代码: #include<iostream> #include<c ...

  6. HDU 5908 Abelian Period (BestCoder Round #88 模拟+暴力)

    HDU 5908 Abelian Period (BestCoder Round #88 模拟+暴力) 题目链接http://acm.hdu.edu.cn/showproblem.php?pid=59 ...

  7. HDU 2802 F(N)(简单题,找循环解)

    题目链接 F(N) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Sub ...

  8. hdu 4891 模拟水题

    http://acm.hdu.edu.cn/showproblem.php?pid=4891 给出一个文本,问说有多少种理解方式. 1. $$中间的,(s1+1) * (s2+1) * ...*(sn ...

  9. hdu 2629 Identity Card (字符串解析模拟题)

    这题是一个字符串模拟水题,给12级学弟学妹们找找自信的,嘿嘿; 题目意思就是要你讲身份证的上的省份和生日解析出来输出就可以了: http://acm.hdu.edu.cn/showproblem.ph ...

随机推荐

  1. vagrant的学习 之 Yii2

    vagrant的学习 之 Yii2 本文根据慕课网的视频教程练习,感谢慕课网! 慕课视频学习地址:https://www.imooc.com/video/14218. 慕课的参考文档地址:https: ...

  2. PHP 基础复习 2018-06-21

    (1)PHP Zip File 函数 $zip = zip_open("test.zip"); if ($zip) { while ($zip_entry = zip_read($ ...

  3. MySql数据库导出csv文件命令

    MySql数据库导出csv文件命令: MySql数据库导出csv文件命令: mysql> select first_name,last_name,email from account into ...

  4. 牛客网暑期ACM多校训练营(第九场)D

    链接:https://www.nowcoder.com/acm/contest/147/D来源:牛客网 Niuniu likes traveling. Now he will travel on a ...

  5. 转 asterisk拨号规则

    asterisk拨号规则 一.前言     本文档以asterisk-1.4.32为基础写作而成,可能和其他版本有些区别. 二.Asterisk dialplan 基本结构 Asterisk dial ...

  6. 一次mysql 优化 (Using temporary ; Using filesort)

    遇到一个SQL执行很慢 SQL 如下: SELECT ... FROM tableA WHERE time >= 1492044535 and time <= 1492046335 GRO ...

  7. WebLogic中"域"的概念

    WebLogic 版权声明:本文为博主原创文章,未经博主允许不得转载. WebLogic Server中的域是逻辑上相关的一组 WebLogic Server 资源,可以作为一个单元进行管理.一个域中 ...

  8. elasticsarch5.4集群安装

    越来越多的企业已经采用ELK解决方案来对其公司产生的日志进行分析,笔者最近着手在生产环境部署自己的ELK stack,本文介绍ELK中elasticsearch5.2集群的实现. 一.环境准备 1.系 ...

  9. input 文本框禁止输入表情

    js在用户输入表情时自动过滤掉 <input type="text" id="input" maxlength="10"/> v ...

  10. webpack-Module Resolution(模块解析)

    模块解析(Module Resolution) resolver 是一个库(library),用于帮助找到模块的绝对路径.一个模块可以作为另一个模块的依赖模块,然后被后者引用,如下: import f ...