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 ...
随机推荐
- bzoj2581 [USACO 2012 Jan Gold] Cow Run【And-Or Tree】
传送门1:http://www.usaco.org/index.php?page=viewproblem2&cpid=110 传送门2:http://www.lydsy.com/JudgeOn ...
- post和get提交服务器编码过程
参考资料:http://blog.csdn.net/z55887/article/details/46975679 先说出一个知识点: 如果浏览器端编码是UTF-8,那在服务器端解决乱码问题的方法有两 ...
- Xcode配置SVN详细步骤
转载:http://blog.csdn.net/weiqubo/article/details/8288635 Xcode 默认自带Git 与 SVN,我们本篇介绍SVN的详细配置步骤如下: 1. ...
- Radis
http://www.redis.cn/ http://try.redis.io/ http://www.redisdoc.com/en/latest/ Redis 命令参考¶ 本文档是 Redis ...
- AJPFX解析Java关键字之assert
Java有许多关键字,但是这个关键字估计很少有人了解,今天就跟大家谈一谈这个关键字吧. 先说明一下,这个关键字开发中用的极少,感兴趣的朋友可以了解一下. 一.概述 在C和C++语言中都有assert关 ...
- jquery 实现 点击把数据移动右侧 点击再次移回到左侧
2018年第一发 希望新的一年和大家一下学习更多知识 JS://把数据左边挪到了右边,再从右边移动回来function moveOption(e1, e2){ $("#" ...
- HTML中的那些bug
1.语法检测时提示有多余的结束标签 <!doctype html> <html> <head> <meta charset="utf-8" ...
- SQL Case 语句的使用
-----简单case 使用 select 学号,姓名, case 专业 when '金融系' then '1' when '材料成型及控制工程' then '2' else '3' end from ...
- swiper移动端下不能正常轮播的解决方案-----此坑没躺过估计很难找到正确姿势
<script> var mySwiper = new Swiper('.swiper-container', { direction: 'vertical', //horizontal横 ...
- 我用的主机,推荐给大家【gegehost】【戈戈主机】
炎炎夏日冰点价格:戈戈主机史上最大优惠促销活动 1.7月1日至8日:买主机优惠大促销:主机买一送一,不限购买数量 请您通过客户中心或者淘宝购买一个主机之后,登录客户中心,提交问题, 提供要赠送的主机的 ...