The Great Pan

Time Limit: 1000ms
Memory Limit: 65536KB

This problem will be judged on HDU. Original ID: 4891
64-bit integer IO format: %I64d      Java class name: Main

 
As a programming contest addict, Waybl is always happy to take part in various competitive programming contests. One day, he was competing at a regional contest of Inventing Crappy Problems Contest(ICPC). He tried really hard to solve a "geometry" task without success.

After the contest, he found that the problem statement is ambiguous! He immediately complained to jury. But problem setter, the Great Pan, told him "There are only four possibilities, why don't you just try all of them and get Accepted?".

Waybl was really shocked. It is the first time he learned that enumerating problem statement is as useful as trying to solve some ternary search problem by enumerating a subset of possible angle!

Three years later, while chatting with Ceybl, Waybl was told that some problem "setters" (yeah, other than the Great Pan) could even change the whole problem 30 minutes before the contest end! He was again shocked.

Now, for a given problem statement, Waybl wants to know how many ways there are to understand it.

A problem statement contains only newlines and printable ASCII characters (32 ≤ their ASCII code ≤ 127) except '{', '}', '|' and '$'.

Waybl has already marked all ambiguity in the following two formats:

1.{A|B|C|D|...} indicates this part could be understand as A or B or C or D or ....
2.$blah blah$ indicates this part is printed in proportional fonts, it is impossible to determine how many space characters there are.

Note that A, B, C, D won't be duplicate, but could be empty. (indicate evil problem setters addedclarified it later.)

Also note that N consecutive spaces lead to N+1 different ways of understanding, not 2N ways.

It is impossible to escape from "$$" and "{}" markups even with newlines. There won't be nested markups, i.e. something like "${A|B}$" or "{$A$|B}" or "{{A|B}|C}" is prohibited. All markups will be properly matched.

 

Input

Input contains several test cases, please process till EOF.
For each test case, the first line contains an integer n, indicating the line count of this statement. Next n lines is the problem statement.
1 ≤ n ≤ 1000, size of the input file will not exceed 1024KB.

 

Output

For each test case print the number of ways to understand this statement, or "doge" if your answer is more than 105.

 

Sample Input

9
I'll shoot the magic arrow several
times on the ground, and of course
the arrow will leave some holes
on the ground. When you connect
three holes with three line segments,
you may get a triangle.
{|It is hole! Common sense!|
No Response, Read Problem
Statement|don't you know what a triangle is?}
1
Case $1: = >$
5
$/*This is my code printed in
proportional font, isn't it cool?*/
printf("Definitely it is cooooooool \
%d\n",4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4
* 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4);$
2
$Two space$ and {blue|
red} color!

Sample Output

4
4
doge
6

Source

 
解题:{}中的计算中的|的个数,然后ans *= (个数+1)
$$中连续的空格,每遇到一个连续的空格,求出其长度ans *= (长度+1);
 
注意要用长整型
 
 #include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <queue>
#include <cstdlib>
#include <string>
#include <set>
#include <stack>
#define LL long long
#define INF 0x3f3f3f3f
using namespace std;
const int maxn = 1e5;
LL ans;
char str[];
int n,len;
int main(){
int i,a,b,cnt,k,j;
while(~scanf("%d",&n)){
getchar();
len = ;
ans = ;
for(i = ; i < n; i++){
gets(str+len);
len = strlen(str);
}
a = b = ;
for(i = ; i < len; i++){
if(a == && str[i] == '$'){
a = ;
}else if(str[i] == '{'){
b = ;
j = ;
}else if(a == && str[i] == '$'){
a = ;
}else if(str[i] == '}'){
b = ;
ans *= j+;
j = ;
}
if(a && str[i] == ' '){
k = ;
while(str[i] == ' '){k++;i++;}
i--;
ans *= (k+);
}
if(b && str[i] == '|'){j++;}
if(ans > maxn) break;
}
if(ans > maxn) puts("doge");
else printf("%I64d\n",ans);
}
return ;
}
 

最新文章

  1. ObjC宏定义小细节
  2. B样条基函数(cubic spline basis)
  3. Memcache基础教程
  4. Android中Animation 详细解读
  5. netbeans项目中排除node_modules文件夹
  6. ajax post提交的方式
  7. [转]android访问网络:java.net.ConnectException: localhost/127.0.0.1:8888 - Connection refused
  8. Linux登录出现modle is unknow
  9. jquery概要--基础02
  10. OAuth2.0协议
  11. Queueing in the Linux Network Stack !!!!!!!!!!!!!!!
  12. CodeForces - 740C
  13. jQuery之标签操作和返回顶部、登录验证、全选反选、克隆示例
  14. 【原创】大叔经验分享(19)spark on yarn提交任务之后执行进度总是10%
  15. 6.03-news_xpath2
  16. springmvc中model可以封装的数据类型
  17. 如何让linux的history命令显示时间记录
  18. Vue框架H5商城类项目商品详情点击返回弹出推荐商品弹窗的实现方案
  19. 58A
  20. 【转】 python中 * 的用法

热门文章

  1. C#中的list的System.Predicate&lt;in T&gt;和System.Comparison&lt;in T&gt;的应用
  2. unix shell 解析 1
  3. Xml学习笔记(1)
  4. SpringBoot_整合视图层技术
  5. Java操作pdf: JarsperReport的简单使用
  6. 在WIndowsPhone8 上制作的简单的计算器
  7. idea 调试工具的使用
  8. ios开发介绍
  9. 基于C++11的call wrapper
  10. Winform中ListView鼠标移动使用toolTip显示信息