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直接下载百度网盘中的资源,此款软件下载速度快,下载压缩 ...
随机推荐
- [转] 查看HDFS文件系统数据的三种方法
1.使用插件——Hadoop-Eclipse-Plugin此方法需要借助Eclipse,插件的安装及使用请参考博文使用Eclipse编译运行MapReduce程序_Hadoop2.6.0_Ubuntu ...
- Spring事务管理之声明式事务管理-基于AspectJ的XML方式
© 版权声明:本文为博主原创文章,转载请注明出处 案例 - 利用Spring的声明式事务(AspectJ)管理模拟转账过程 数据库准备 -- 创建表 CREATE TABLE `account`( ` ...
- linux把某个文件拷贝到不同的目录下面
find -name '7*' -type d|xargs -n 1 cp PBClassname.properties
- Prometheus+Grafana搭建监控系统
之前在业务中遇到服务器负载过高问题,由于没有监控,一直没发现,直到业务方反馈网站打开速度慢,才发现问题.这样显得开发很被动.所以是时候搭建一套监控系统了. 由于是业余时间自己捯饬,所以神马业务层面的监 ...
- 使用ffmpeg下载m3u8流媒体
安装 编译好的windows可用版本的下载地址(官网中可以连接到这个网站,和官方网站保持同步): http://ffmpeg.zeranoe.com/builds/ 或者: 百度网盘https://p ...
- 生成JNI的DLL时提示找不到jni.h的解决的方法Cannot open include file: 'jni.h': No such file or directory
解决的方法: 就是到jdk的安装文件夹下include下把下面对应的文件,拷贝到vc文件夹下的include文件夹下 \jdk\include\jni.h \jdk\include\win32\jaw ...
- phalcon builder get raw sql
$this->modelsManager->createBuilder()->from('table')->where('a = "a"')->lim ...
- 2016 acm香港网络赛 B题. Boxes
原题网址:https://open.kattis.com/problems/boxes Boxes There are N boxes, indexed by a number from 1 to N ...
- Android屏幕密度(Density)和分辨率概念详解
移动设备有大有小,那么如何适应不同屏幕呢,这给我们编程人员造成了很多困惑.我也是突然想到这些问题,然后去网上搜搜相关东西,整理如下. 首先,对下面这些长度单位必须了解. Android中的长度单位 ...
- hdu4063(圆与圆交+线段与圆交+最短路)
写几何题总是提心吊胆.精度问题真心吓人. 其实思路挺简单的一道题,真是什么算法和几何double搞到一块,心里就虚虚的. 思路:求出所有圆之间的交点,然后用这些交点跑一遍最短路就可以了. Aircra ...