hdu 4891 模拟水题
http://acm.hdu.edu.cn/showproblem.php?pid=4891
给出一个文本,问说有多少种理解方式。
1. $$中间的,(s1+1) * (s2+1) * ...*(sn+1), si表示连续的空格数。
2.{}中间,即 | 的个数+1.
就是模拟
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
#define RD(x) scanf("%d",&x)
#define RD2(x,y) scanf("%d%d",&x,&y)
#define clr0(x) memset(x,0,sizeof(x))
typedef long long LL;
#define N 100005 int n;
string x , y; LL check(int l , int r){
LL ans = 1,tmp = 1;
for (int i=l;i<=r;++i){
if (x[i] == ' ')
++tmp;
else{
ans *= tmp;
tmp = 1;
if (ans > 100000)
return -1;
}
}
return ans;
} LL checkk(int l , int r){
LL ans = 1;
for (int i=l;i<=r;++i)
if (x[i] == '|') ++ans;
return ans;
} void work(){
getchar();
x = "";
while (n--){
getline(cin,y);
x += y;
}
int m = x.size();
LL ans = 1 , now;
for(int i = 0;i < m;){
while (x[i] != '$' && x[i] != '{' && i < m) ++i;
if (i == m) break;
int j = i+1;
if (x[i] == '$'){
while (x[j] != '$') ++j;
now = check(i,j);
} else {
while (x[j] != '}') ++j;
now = checkk(i,j);
}
if (now == -1){
puts("doge");
return;
}
ans *= now;
if (ans > 100000){
puts("doge");
return;
}
i = j+1;
}
printf("%I64d\n",ans);
} int main(){
while (~RD(n))
work();
return 0;
}
hdu 4891 模拟水题的更多相关文章
- hdu 5003 模拟水题
http://acm.hdu.edu.cn/showproblem.php?pid=5003 记得排序后输出 #include <cstdio> #include <cstring& ...
- hdu 5003 模拟水题 (2014鞍山网赛G题)
你的一系列得分 先降序排列 再按0.95^(i-1)*ai 这个公式计算你的每一个得分 最后求和 Sample Input12530 478Sample Output984.1000000000 # ...
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- POJ 2014:Flow Layout 模拟水题
Flow Layout Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 3091 Accepted: 2148 Descr ...
- hdu 5210 delete 水题
Delete Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5210 D ...
- hdu 1251 (Trie水题)
统计难题 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131070/65535 K (Java/Others)Total Submi ...
- hdu 5083 有坑+字符串模拟水题
http://acm.hdu.edu.cn/showproblem.php?pid=5083 机器码和操作互相转化 注意SET还要判断末5位不为0输出Error #pragma comment(lin ...
- HDU 6213 Chinese Zodiac 【模拟/水题/生肖】
Problem Description The Chinese Zodiac, known as Sheng Xiao, is based on a twelve-year cycle, each y ...
- HDU 5703 Desert 水题 找规律
已知有n个单位的水,问有几种方式把这些水喝完,每天至少喝1个单位的水,而且每天喝的水的单位为整数.看上去挺复杂要跑循环,但其实上,列举几种情况之后就会发现是找规律的题了= =都是2的n-1次方,而且这 ...
随机推荐
- linux命令行下执行循环动作
在当前子目录下分别创建x86_64 for dir in `ls `;do (cd $dir;mkdir x86_64);done
- html 转化成 pdf
- 20172325 2017-2018-2 《Java程序设计》第十一周学习总结
20172325 2017-2018-2 <Java程序设计>第十一周学习总结 教材学习内容总结 Android简介 Android操作系统是一种多用户的Linux系统,每个应用程序作为单 ...
- VS Installer教程
本文主要讲解利用VS2010下的Visual Studio Installer打包Zigbee程序(VS2010编写)的过程. 1.打开Zigbee程序,在解决方案中添加“新建项目”-->其他项 ...
- ui设计教程分享:关于Logo设计要素
1. 视觉上”一语双关 我最喜欢的一些Logo在视觉设计上”一语双关”,将两张图片.两张意象巧妙结合,合二为一. WinePlace 的Logo就是一个绝佳的案例 这个Logo看起来像图钉,暗喻着 ...
- Spring Boot REST(二)源码分析
Spring Boot REST(二)源码分析 Spring 系列目录(https://www.cnblogs.com/binarylei/p/10117436.html) SpringBoot RE ...
- [AI]神经网络章2 神经网络中反向传播与梯度下降的基本概念
反向传播和梯度下降这两个词,第一眼看上去似懂非懂,不明觉厉.这两个概念是整个神经网络中的重要组成部分,是和误差函数/损失函数的概念分不开的. 神经网络训练的最基本的思想就是:先“蒙”一个结果,我们叫预 ...
- Continuous Subarray Sum LT523
Given a list of non-negative numbers and a target integer k, write a function to check if the array ...
- python 的文件操作
二进制用法 f=open('test.txt','wb') f.write("汉字\r\n".encode('UTF-8')) f.write("hello". ...
- android模拟器不能上网设置
进行sdk目录中的platform-tools目录: adb devices 系统会罗列出所有设置 adb -s emulator- shell 最后设置网关 setprop net.dns1 192 ...