题意:给定一个文章,问你有多少种读法,计算方法有两种,如果在$中,如果有多个空格就算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. CSS属性操作二

    9.float属性 基本浮动规则 先来了解一下block元素和inline元素在文档流中的排列方式. block元素通常被现实为独立的一块,独占一行,多个block元素会各自新起一行,默认block元 ...

  2. Xcode warning:Auto property synthesis will not synthesize property

    iOS 警告提示如下: 添加 @dynamic告诉编译器这个属性是动态的,动态的意思是等你编译的时候就知道了它只在本类合成; 如下:

  3. CodeForces 598C Nearest vectors

    这题对精度要求很高.用atan2吧... #include<iostream> #include<cstring> #include<cmath> #include ...

  4. poj 3041——Asteroids

    poj       3041——Asteroids Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22604   Accep ...

  5. Wannafly模拟赛2 B river(拉格朗日乘数法)

    题目 https://www.nowcoder.com/acm/contest/4/B题意 有n条南北流向的河并列排着,水流速度是v,现在你需要从西岸游到东岸,总共T个时间,你的游泳速度是u,问东岸的 ...

  6. Java添加、提取、替换和删除PDF图片

    (一)简介 这篇文章将介绍在Java中添加.提取.删除和替换PDF文档中的图片. 工具使用: Free Spire.PDF for JAVA 2.4.4(免费版) Intellij IDEA Jar包 ...

  7. Spring4MVC 请求参数映射和Content-type

    目录 前言 不使用注解(不传则为null) 基本数据类型和日期类型 自定义类型POJO @PathVariable注解 @RequestParam 注解 @RequestBody注解 复杂对象Arra ...

  8. javax/servlet/ServletContext : Unsupported major.minor version 51.0

    原文:http://blog.csdn.net/mlin_123/article/details/50738532 解决:将版本从 3.1.0 改为 3.0.1 <!-- 添加servlet A ...

  9. cef3的各个接口你知道几个

    CEF3基本的框架包含C/C++程 序接口,通过本地库的接口来实现,而这个库则会隔离宿主程序和 Chromium&Webkit的操作细节.它在浏览器控件和宿主程序之间提供紧密的整合,它支持用户 ...

  10. curl的使用(from 阮一峰)

    1.   http://www.ruanyifeng.com/blog/2011/09/curl.html 2.   https://curl.haxx.se/docs/httpscripting.h ...