BNUOJ 35759 The Great Pan
The Great Pan
This problem will be judged on HDU. Original ID: 4891
64-bit integer IO format: %I64d Java class name: Main
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
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
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
#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 ;
}
BNUOJ 35759 The Great Pan的更多相关文章
- BNUOJ 52325 Increasing or Decreasing 数位dp
传送门:BNUOJ 52325 Increasing or Decreasing题意:求[l,r]非递增和非递减序列的个数思路:数位dp,dp[pos][pre][status] pos:处理到第几位 ...
- bnuoj 24251 Counting Pair
一道简单的规律题,画出二维表将数字分别相加可以发现很明显的对称性 题目链接:http://www.bnuoj.com/v3/problem_show.php?pid=24251 #include< ...
- php7+apache2.4 (Windows7下),成功启动。(楼主另外提供了1个php7集成环境打包: http://pan.baidu.com/s/1qXwjpF2 ,如果你只是想了解一下,放在d盘根目录。)
php7正式版已经发布,性能是php5.4的2倍.博主入手php7 新鲜了一把,下面是解决问题之后成功启动php7的记录. ( 电脑必须win7 sp1, .netframework4 ) Windo ...
- Kettle_使用Pan.bat执行转换、Kitchen.bat执行作业
参考资料:http://www.cnblogs.com/wxjnew/p/3620792.html 注意:使用bat文件执行速度比执行在spoon.bat中执行慢很多 一.使用Pan.bat执行转换 ...
- bnuoj 44359 快来买肉松饼
http://www.bnuoj.com/contest/problem_show.php?pid=44359 快来买肉松饼 Time Limit: 5000 ms Case Time Lim ...
- iOS开发 在scrollView上增加滑动手势(Pan)
view上有一个scrollView,现在想在view上加一个Pan手势,需求是:当向下划的时候,整个view动,但是scrollView不动:其它情况下scrollView动而view不动. -(B ...
- BNUOJ 1006 Primary Arithmetic
Primary Arithmetic 来源:BNUOJ 1006http://www.bnuoj.com/v3/problem_show.php?pid=1006 当你在小学学习算数的时候,老师会教你 ...
- bnuoj 34985 Elegant String DP+矩阵快速幂
题目链接:http://acm.bnu.edu.cn/bnuoj/problem_show.php?pid=34985 We define a kind of strings as elegant s ...
- bnuoj 25659 A Famous City (单调栈)
http://www.bnuoj.com/bnuoj/problem_show.php?pid=25659 #include <iostream> #include <stdio.h ...
随机推荐
- java数组实现买彩票(二个一维数组的比较思想)
/** 设计一个程序,模拟从彩球池里随机抽取5个彩球(彩球池里一共有11个彩球,编号为1~11), 要求在控制台打印出这5个被取出来的彩球的编号(注意编号不能重复). 思路: 1.创建一个int类型的 ...
- java awt 乱码问题
问题:项目环境是utf-8,awt的元件比如label一直乱码 解决: (eclipse) 1.在你的具有main函数的类也即你应用运行的主类上点击右键,选择Run As中的Run Configura ...
- 449 Serialize and Deserialize BST 序列化和反序列化二叉搜索树
详见:https://leetcode.com/problems/serialize-and-deserialize-bst/description/ C++: /** * Definition fo ...
- SpringMVC与请求控制器
MVC设计模式 视图(View) -对应组件:JSP或者HTML文件 控制器(controller) -对应组件:Servlet 模型(Model) -对应组件:JavaBean MVC ...
- (一)Spring之初了解
1.认识 Spring 框架 Spring 框架是 Java 应用最广的框架,它的成功来源于理念,而不是技术本身,它的理念包括 IoC (Inversion of Control,控制反转) 和 AO ...
- C#过时方法标记
1.当遇到过时或废弃的方式 函数怎么办 [Obsolete]特性解决你的困惑 1.1:当方法已经完成相关兼容 可以保留时
- Android 图片文件和Bitmap之间的转换
String filePath="c:/01.jpg"; Bitmap bitmap=BitmapFactory.decodeFile(filePath); 如果图片过大,可能导致 ...
- iOS Programming Views :Redrawing and UIScrollView
iOS Programming Views :Redrawing and UIScrollView 1.1 event You are going to see how views are red ...
- CSS3 动画-- 鼠标移上去,div 会旋转、放大、移动
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- CS2QS
inline QString MotorCS2QS(CString cs) { return QString::fromWCharArray((LPCTSTR)cs, cs.GetLength()); ...