HDU--4891--The Great Pan--暴力搜索
The Great Pan
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.
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.
105.
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!
4
4
doge
6
题意:假设是{},求当中的 “ | ” 的个数,然后加一乘到总和里面。假设是 $ $ 。求当中空格,连续的n个空格有n+1种方式。$ $ 中的空格段之间的计算也是直接相乘,然后乘到总和里面
体验过什么叫WA到死么?-.-!不罗嗦了。注意的就是当中的方式总量是会超过int范围的。所以要及时推断出来。另一个。也就是把我卡了半天的,就是推断文件大小,每次输入最大文件是1024KB,一个字符是1B,所以每次输入的字符串长度都是百万++的 T.T 所果断开了500W的才过
代码太简单,所以不凝视了
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
char str[5000000];
int main (void)
{
int n,i,j,k,l;
__int64 num,s;
while(~scanf("%d%*c",&n))
{
num=1;
k=0;
s=0;
while(n--&&gets(str))
{
l=strlen(str);
if(num>100000)continue;
for(i=0;i<l;i++)
{
if(str[i]=='$'||str[i]=='{'||str[i]=='}')
{
if(k!=0)
{
if(num*(s+1)>100000)
{
num=100001;
break;
}
num*=s+1;
s=0;
k=0;
}
else if(str[i]=='$')k=1;
else k=2;
}else if(k==1)
{
if(str[i]==' ')
{
s++;
if(s>=100000)
{
num=100001;
break;
}
}
else
{
if(num*(s+1)>100000)
{
num=100001;
break;
}
num*=s+1;
s=0;
}
}else if(k==2)
{
if(str[i]=='|')
{
s++;
if(s>=100000)
{
num=100001;
break;
}
}
}
}
}
if(num>100000)puts("doge");
else printf("%I64d\n",num);
}
return 0;
}
HDU--4891--The Great Pan--暴力搜索的更多相关文章
- HDU 4891 The Great Pan (字符串处理)
题目链接:HDU 4891 The Great Pan 求一串字符有多少种不同的意思,当中关心'{','}'之间的'|'. 和'$','$'之间的空格,连续N个空格算N+1种. AC代码: #incl ...
- HDU 2616 Kill the monster (暴力搜索 || 终极全阵列暴力)
主题链接:HDU 2616 Kill the monster 意甲冠军:有N技能比赛HP有M怪物,技能(A,M),能伤害为A.当怪兽HP<=M时伤害为2*A. 求打死怪兽(HP<=0)用的 ...
- HDU 4891 The Great Pan (模拟)
The Great Pan 题目链接: http://acm.hust.edu.cn/vjudge/contest/123554#problem/D Description As a programm ...
- HDU 1399 Starship Hakodate-maru(暴力搜索)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1399 Starship Hakodate-maru Time Limit: 2000/1000 MS ...
- hdu 1399 Starship Hakodate-maru (暴力搜索)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1399 题目大意:找到满足i*i*i+j*(j+1)*(j+2)/6形式且小于等于n的最大值. #inc ...
- 2014多校第三场1005 || HDU 4891 The Great Pan(模拟)
题目链接 题意 : 给你n行字符串,问你有多少种理解方式.有两大类的理解 (1){A|B|C|D|...}代表着理解方式可以是A,可以是B或C或者D. (2)$blah blah$,在$$这两个符号中 ...
- HDU 4891 The Great Pan
模拟题. #include<map> #include<set> #include<ctime> #include<cmath> #include< ...
- HDU 4891 The Great Pan (题意题+模拟)
题意:给定一个文章,问你有多少种读法,计算方法有两种,如果在$中,如果有多个空格就算n+1,如果是一个就算2的次方,如果在{}中, 那么就是把每个空格数乘起来. 析:直接模拟,每次计算一行,注意上一行 ...
- 2014联合三所学校 (HDU 4888 HDU 4891 HDU 4893)
HDU 4891 The Great Pan 注册标题 他怎么说,你怎么样 需要注意的是乘法时,它会爆炸int 代码: #include<iostream> #include<c ...
- hdu 4740 The Donkey of Gui Zhou(暴力搜索)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4740 [题意]: 森林里有一只驴和一只老虎,驴和老虎互相从来都没有见过,各自自己走过的地方不能走第二次 ...
随机推荐
- python的装饰器,迭代器用法
装饰器. 装饰器实际就是一个函数 定义:在不改变内部代码和调用方式的基础上增加新的功能 了解装饰器需要了解3个内容: 1.函数即变量 2.高阶函数 1).把一个函数名当作实参传给另一个函数 2).返回 ...
- pytorch 5 classification 分类
import torch from torch.autograd import Variable import torch.nn.functional as F import matplotlib.p ...
- 小学生都能学会的python(字典{ })
小学生都能学会的python(字典{ }) 1. 什么是字典 dict. 以{}表示. 每一项用逗号隔开, 内部元素用key:value的形式来保存数据 {"jj":"林 ...
- JavaCodeTra 36选7 彩票抽奖
想写个小代码试试自己的运气.然并卵.并不能猜中 import java.util.Random; import java.util.Scanner; /** * */ /** * @author Ha ...
- 计算机网络 4.网络层与IP协议
网络中的每一台主机和路由器都有一个网络层部分.而路由器中也没有网络层以上的层次.网络层是协议栈中最复杂的层次. 转发forwarding:当一个分组到达某路由器的输入链路时.该路由器将分组移动到适当的 ...
- IOS 数据存储之 SQLite具体解释
在IOS开发中常常会须要存储数据,对于比較少量的数据能够採取文件的形式存储,比方使用plist文件.归档等,可是对于大量的数据,就须要使用数据库,在IOS开发中数据库存储能够直接通过SQL訪问数据库, ...
- BZOJ 1264: [AHOI2006]基因匹配Match 树状数组+DP
1264: [AHOI2006]基因匹配Match Description 基因匹配(match) 卡卡昨天晚上做梦梦见他和可可来到了另外一个星球,这个星球上生物的DNA序列由无数种碱基排列而成(地球 ...
- yolo源码解析(1):代码逻辑
一. 整体代码逻辑 yolo中源码分为三个部分,\example,\include,以及\src文件夹下都有源代码存在. 结构如下所示 ├── examples │ ├── darknet.c(主程序 ...
- zzulioj--1786--求最大值(技巧题)
1786: 求最大值 Time Limit: 1 Sec Memory Limit: 128 MB Submit: 222 Solved: 46 SubmitStatusWeb Board Des ...
- TCP、HTTP协议的RPC
TCP.HTTP协议的RPC 1.1 基于TCP协议的RPC 1.1.1 RPC名词解释 RPC的全称是Remote Process Call,即远程过程调用,RPC的实现包括客户端和服务端,即服务调 ...