走上模拟道路 HDU4891
http://vjudge.net/contest/view.action?cid=51327#problem/D
Description
Input
Output
Sample Input
| input |
|---|
(We) [are] {blind}, if (we) [could not see] {creation of this clone army}
|
| output |
Blind we are, if creation of this clone army we could not see |
| input |
{Truly wonderful} (the mind of a child) [is]
|
| output |
Truly wonderful the mind of a child is |
#include <iostream>
#include <cstring>
#include <cstdio> using namespace std; char str[];
char ob[],sub[],veb[];
int o,sb,ve;
int i,j;
int len,star; int main()
{
while(gets(str))
{
star=;
o=sb=ve=;
len=strlen(str);
for(i=;i<len;i++)
{
if(str[i]=='(')
{
i++;
while(i<len&&str[i]!=')')
{
sub[sb++]=str[i++];
}
} else if(str[i]=='{')
{
i++;
while(i<len&&str[i]!='}')
{
ob[o++]=str[i++];
}
}
else if(str[i]=='[')
{
i++;
while(i<len&&str[i]!=']')
{
veb[ve++]=str[i++];
}
}
else
{
if(str[i]==',')
{
for(j=;j<o;j++)
{
if(star)
{
if(ob[]>='a'&&ob[]<='z')
{
putchar(ob[]-);
}
else putchar(ob[]);
star=;
continue;
}
putchar(ob[j]);
}
putchar(' ');
o=;
for(j=;j<sb;j++)
{
if(j==&&sub[]<='Z'&&sub[]>='A')
putchar(sub[j]+);
else putchar(sub[j]);
}
putchar(' ');
sb=;
for(j=;j<ve;j++)
{
if(j==&&veb[]<='Z'&&veb[]>='A')
putchar(veb[j]+);
else putchar(veb[j]);
}
ve=;
putchar(',');
i++;
while(str[i]!='{'&&str[i]!='('&&str[i]!='[')
{
if(i<len){
putchar(str[i]);
i++;
}
else
{
break;
}
}
i--;
}
}
}
if(o||sb||ve)
{
for(j=;j<o;j++)
{
if(star)
{
if(ob[]>='a'&&ob[]<='z')
{
putchar(ob[]-);
}
else putchar(ob[]);
star=;
continue;
}
putchar(ob[j]);
}
putchar(' ');
for(j=;j<sb;j++)
{
if(j==&&sub[]<='Z'&&sub[]>='A')
putchar(sub[j]+);
else putchar(sub[j]);
}
putchar(' ');
for(j=;j<ve;j++)
{
if(j==&&veb[]<='Z'&&veb[]>='A')
putchar(veb[j]+);
else putchar(veb[j]);
}
}
putchar('\n');
}
return ;
}
putchar(); 字符输出 与cout没有其他差别
eg:putchar('a'-32)==A
cout<<'a'-32<<endl; ==65
The Great Pan
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1003 Accepted Submission(s): 352
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 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.
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
doge
6
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring> using namespace std;
#define LL long long char str1[];
char str[]; int main()
{
int n;
while(scanf("%d",&n) != EOF)
{
memset(str,'/0',sizeof(str));
LL ans = ;
LL tans=;
int len = ;
getchar();
for(int i = ; i <= n; i ++)
{
gets(str1);
int len1 = strlen(str1);
for(int j = ; j < len1 ; j++)
str[j+len] = str1[j];
len = len + len1;
} int is = ;
int t = ;
int ok = ; for(int i = ; i < len ; i ++)
{
if(ok == )
break;
if(is)
{
if(str[i] == ' ')
{
t++;
if(str[i+] != ' ')
{
tans *=(t+);
t = ;
}
}
else if(str[i] == '$')
{
is = ;
ans = tans * ans;
tans = ;
}
if(tans > )
{
ok = ;
}
}
else
{
if(str[i] == '{')
{
int t = ;
int j ;
for(j = i +; ; j ++)
{
if(str[j] == '}')
break;
if(str[j] == '|')
t ++ ;
}
i = j;
ans *= t ;
if(ans > )
{
ok = ;
}
}
else
{
if(str[i] == '$')
is = ;
}
}
}
if(ok )
printf("doge\n");
else
printf("%I64d\n",ans);
}
return ;
}
走上模拟道路 HDU4891的更多相关文章
- 是什么让我走上Java之路?
选择方向,很多人都为根据自己的兴趣爱好和自己的能力所长而作出选择.那么是什么让我走上Java之路? 整个高三我有两门课程没有听过课,一门是数学,一门是物理.当时候物理没有听课的原因很简单,我有一本&l ...
- Windows上模拟Linux环境的软件Cygwin
Windows上模拟Linux环境的软件Cygwin 2010-10-11 15:19 我要评论(0) 字号:T|T Cygwin是一个用于在Windows上 模拟Linux环境的软件.它可 ...
- 【文学文娱】《屌丝逆袭》-出任CEO、迎娶白富美、走上人生巅峰
本文地址:http://www.cnblogs.com/aiweixiao/p/7759790.html 原文地址:(微信公众号) 原创 2017-10-30 微信号wozhuzaisi 程序员的文娱 ...
- delphi 在桌面屏幕上模拟鼠标单击
delphi 在桌面屏幕上模拟鼠标单击 procedure TFrmUnicom.Button1Click(Sender: TObject); var oldPoint, newPoint: TPoi ...
- 数据库最佳实践:DBA小马如何走上升值加薪之路?
DBA可能是互联网公司里面熬夜最多,背锅最多的岗位之一,腾讯云数据库团队的同学结合自身的成长经历,用漫画的形式为我们分享了一位DBA是如何从菜鸟成长为大神,走上升职加薪,迎娶白富美之路的. 此文已由作 ...
- 神户制钢坑了500家企业 百年老店为何走上邪路?(企业经营再艰难,也不能降低产品质量,甚至偷工减料,同样适用于IT行业)
神户制钢这颗烂萝卜,拔出它之后带出的泥越来越多.上周五社长川崎博也又开了记者会,再次道歉,而受到其数据造假影响的客户数量也从200家飙升到500家. 日本政府给神户制钢两周时间调查,还要在一个月内公布 ...
- PUToast - 使用PopupWindow在Presentation上模拟Toast
PUToast Android10 (API 29) 之前 Toast 组件默认只能展示在主 Display 上,PUToast 通过构造一个 PopupWindoww 在 Presentation ...
- 运用Mono.Ceci类库修改.NET程序集 走上破解软件的道路
代码注入在C++时代很流行,主要是对现有的程序做一些修改,以达到预期的目的.一部分的破解程序,注册机也是借助于此方法,让被注入的程序绕过验证,达到破解的目录.在.NET中,借助于Mono.Cecil程 ...
- python 之走坑的道路
### python之 继续走函数的坑 上篇文章简单介绍了函数的一些简单的使用,这次继续踩函数的坑1.函数对象 函数其实也可以当做一个参数传给另一个函数,也可以使用赋值的方式来给另一个,而且这两个的内 ...
随机推荐
- tar 解压某个指定的文件或者文件夹
1. 先查看压缩文档中有那些文件,如果都不清楚文件内容,然后就直接解压,这个是不可能的 使用#tar -tf 压缩包名称,可以查看压缩包内容 2.解压某个文件 tar -zxvf zabbix.tar ...
- Centos PS1
PS1="[\[\e[35m\]\u\[\e[m\]\[\e[31m\]->\[\e[m\]\[\e[33m\]\H\[\e[m\]\[\e[31m\]->\[\e[m\]\[\ ...
- vim窗口切换
参考资料: http://www.cnblogs.com/litifeng/p/8282479.html 当用vim写代码的时候,我喜欢一边看着头文件中结构的定义,一边编写实现的代码,这样就经常用到多 ...
- Vue router 全局路由守卫
记录一下全局路由守卫的使用: 方法一:定义一个数组用于检测与管理需要登录的页面,全局路由守卫配合本地存储判断是否跳转 import Vue from 'vue' import Router from ...
- Aspose.Words给word文档加水印
需求:在一些重要的Word文档需要打印时,添加水印以明出处. 方案:使用Aspose组件给word文档 代码:干货如下 /// <summary> /// Inserts a waterm ...
- 获取JavaScript异步函数的返回值
今天研究一个小问题: 怎么拿到JavaScript异步函数的返回值? 1.错误尝试 当年未入行时,我的最初尝试: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 <s ...
- Flex 确定弹出窗口的绝对位置x , y
var selectbox:Selectbox; selectbox = new SelectBox(); var pt:Point = new Point(0,0); pt = this.paren ...
- spring学习 五 依赖注入的方式
依赖注入有两种方式: 1 构造注入,如果<bean>标签下使用<contructor-arg>,则是构造注入 2 setter注入,就是调用setter方法注入,如果<b ...
- 检测鼠标是否在UI上unity
public static bool IsCursorOnUI(int inputID=-1){ EventSystem eventSystem = EventSystem.current; retu ...
- mysql之表与表关联和表操作
一 表于表之间的关联 foregin key:设置外键表于表之间建立关联. 多对一关联: 创建步骤,应该先创建好被关联的那一张表,然后再去创建关联的那一张表. 关联表的多条对应着被关联的那张表的一条记 ...