The Great Pan
Description
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 2 N 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
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
D - The Great Pan
Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u
Submit Status Description
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 2 N 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
#include<stdio.h>
#include<string.h> char a[500000]; int main()
{
long long i,n,flag,ans,sum,flag2,num; while(scanf("%lld%*c",&n)!=EOF)
{
memset(a,0,sizeof(a)); for(i=0;i<n;i++)
{
gets(a+strlen(a));
}
//puts(a); flag=0;
flag2=0;
num=1;
ans=1; for(i=0; a[i]!='\n'; i++)
{
if(a[i]=='{')
{
flag=1;
sum=1;
}
if(a[i]=='}')
{
flag=0;
ans*=sum;
//printf("1%d* ", ans );
}
if(flag==1)
{
if(a[i]=='|')
sum++;
} if( flag2==1 && a[i]!=' ' && a[i-1]==' ')
{
ans*=num;
//printf("2%d* ", ans );
num=1;
} if(a[i]=='$')
{
if(flag2==0)
flag2=1;
else
flag2=0;
num=1;
}
if(flag2==1&&a[i]==' ')
num++;
if(ans>100000)
break;
}
if(ans>100000)
puts("doge");
else
printf("%lld\n",ans);
}
return 0;
}
The Great Pan的更多相关文章
- 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执行转换 ...
- iOS开发 在scrollView上增加滑动手势(Pan)
view上有一个scrollView,现在想在view上加一个Pan手势,需求是:当向下划的时候,整个view动,但是scrollView不动:其它情况下scrollView动而view不动. -(B ...
- HDU 4891 The Great Pan (模拟)
The Great Pan 题目链接: http://acm.hust.edu.cn/vjudge/contest/123554#problem/D Description As a programm ...
- Pentaho Data Integration (三) Pan
官网连接: http://wiki.pentaho.com/display/EAI/Pan+User+Documentation Pan Pan 是一个可以执行使用Spoon编辑的transforma ...
- pan
百度云盘地址第一季http://pan.baidu.com/share/link?shareid=198342&uk=1191518428第二季http://pan.baidu.com/sha ...
- UESTC 1272 Final Pan's prime numbers(乱搞)
题目链接 Description Final Pan likes prime numbers very much. One day, he want to find the super prime n ...
- ANSI X9.8标准 PIN xor PAN获取PIN BlOCK
ANSI X9.8标准 PIN xor PAN获取PIN BlOCK 之前看到几篇介绍,把ANSI说成16个字节,真心扯淡,各种误人子弟,真正的ANSI算法其实是8个字节,具体格式如下: (1) AN ...
- Java实现3DES加密--及ANSI X9.8 Format标准 PIN PAN获取PIN BlOCK
1, 采用银联ANSI X9.8标准 PIN xor PAN获取PIN BlOCK 2, 采用3Des进行加密 参考: des和3Des加密算法实现 要点:因为3DES是对称加密算法,key是24位, ...
- 百度网盘不限速下载软件 Pan Download
百度网盘不限速下载软件 Pan Download Pan Download下载软件是一款电脑端的快速下载器软件,您可以通过Pan Download直接下载百度网盘中的资源,此款软件下载速度快,下载压缩 ...
随机推荐
- vi/vim复制粘贴命
1. 选定文本块.使用v进入可视模式,移动光标键选定内容. 2.复制的命令是y,即yank(提起) ,常用的命令如下: y 在使用v模式选定了某一块的时候,复制选定块到缓冲区用: ...
- linux 登陆key生成
1.登录A机器 2.ssh-keygen -t rsa,将会生成密钥文件和私钥文件 id_rsa,id_rsa.pub或id_dsa,id_dsa.pub Generating public/priv ...
- mac eclipse 删除不用的workspace
file--->switch workspace---->other 点击 recent workspace--->选中删除即可
- python unittest不执行"if __name__ == '__main__' "问题(Pycharm)
问题: 1.selenium导入unittest框架和HtmlReport框架后,HtmlReport不被执行. 2.IDE为Pycharm 假设代码为: from selenium import w ...
- 【Java并发编程】并发编程大合集
转载自:http://blog.csdn.net/ns_code/article/details/17539599 为了方便各位网友学习以及方便自己复习之用,将Java并发编程系列内容系列内容按照由浅 ...
- linux 时间与本地时间不对应解决办法
date -s '2015-01-22 13:00:22' #设置时间 clock -w #写入mac操作系统中 -------------------------------------date - ...
- 10 Memcached 一致性哈希分布式算法原理与实现[PHP实现]
<?php header("Content-type:text/html;charset=utf-8"); interface hash{ public function _ ...
- 如何通过js处理相同时间的信息整合到一起的问题
背景: 倘若后台已经处理好了时间,也就是 今天,昨天,显示具体日期,那么通过js如何写才能调整成如下形式呢? 今天: 第一条数据 第二条数据 昨天: 第一条数据 第二条数据 具体时间: 第一条数据 第 ...
- Android源码及repo下载——亲自测试下载源码成功!
经过一段时间煞费苦心的下载都未能成功后,如今终于把android源代码下载成功,很是兴奋! 废话不多说,直接说下步骤: 1.安装git和curl:sudo apt-get install git-co ...
- Cassandra数据库Java訪问
针对的时Cassandra 2.0 数据库 Java本地client訪问Cassandra,首先建立Javaproject,使用Maven进行管理. 引入依赖: <dependency> ...