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次方,而且这 ...
随机推荐
- PAT 1081 检查密码(15) (代码+思路)
1081 检查密码(15 分) 本题要求你帮助某网站的用户注册模块写一个密码合法性检查的小功能.该网站要求用户设置的密码必须由不少于6个字符组成,并且只能有英文字母.数字和小数点 .,还必须既有字母也 ...
- 迈科DPI和运营商合作比较多
业界领先的DPI/DFI解决方案提供商 专注网络流量数据和应用性能数据的分析优化 业界领先的DPI/DFI解决方案提供商 专注网络流量数据和应用性能数据的分析优化 Previous Next DP ...
- Cannot load JDBC driver class 'oracle.jdbc.OracleDriver'
项目报这个错误,后来查了,是缺少ojdbc,也就是java操作oracle的包,通过https://mvnrepository.com/artifact/oracle/ojdbc/1.4,可以找到该包 ...
- LaTeX数学公式大全
原写于我的洛谷博客(传送门),现搬到这个博客上. 建议去洛谷博客上看,因为两边的编辑器在有些功能上不能通用,所以之后若有删改或新增内容只在洛谷博客上弄,这边就懒得改了. 原本是针对洛谷的编辑器,不过懒 ...
- HDU 3407.Zjnu Stadium 加权并查集
Zjnu Stadium Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tota ...
- How to change and add some params to request in Laravel controller?
$request->merge([ 'aae_id' => request('id', 0), 'foo' => 'bar', ]);
- linux内socket服务器无法连接windows
今天在试socket的时候出现了一个问题:问题概述是这样的: 1.linux采用centOS7(mini)版本,虚拟机版本VMware12,网卡设置NAT 2.服务器和客户端都在windows上,通讯 ...
- Arithmetic Slices LT413
A sequence of number is called arithmetic if it consists of at least three elements and if the diffe ...
- CSS实现背景透明而背景上的文字不透明
在我们设计制作一些网页的时候可能会用到半透明的效果,首先我们可能会想到用PNG图片处理,当然这是一个不错的办法,唯一的兼容性问题就是ie6 下的BUG,但这也不困难,加上一段js处理就行了.但假如我们 ...
- mysql主从配置思路
记录一下 原文:http://www.rjfw.com.cn/qamain/prevView.action?id=40482017200000031 mysql主从配置(清晰的思路) mysql主从配 ...