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 模拟水题的更多相关文章

  1. hdu 5003 模拟水题

    http://acm.hdu.edu.cn/showproblem.php?pid=5003 记得排序后输出 #include <cstdio> #include <cstring& ...

  2. hdu 5003 模拟水题 (2014鞍山网赛G题)

    你的一系列得分 先降序排列 再按0.95^(i-1)*ai 这个公式计算你的每一个得分 最后求和 Sample Input12530 478Sample Output984.1000000000 # ...

  3. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  4. POJ 2014:Flow Layout 模拟水题

    Flow Layout Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 3091   Accepted: 2148 Descr ...

  5. hdu 5210 delete 水题

    Delete Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5210 D ...

  6. hdu 1251 (Trie水题)

    统计难题 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131070/65535 K (Java/Others)Total Submi ...

  7. hdu 5083 有坑+字符串模拟水题

    http://acm.hdu.edu.cn/showproblem.php?pid=5083 机器码和操作互相转化 注意SET还要判断末5位不为0输出Error #pragma comment(lin ...

  8. HDU 6213 Chinese Zodiac 【模拟/水题/生肖】

    Problem Description The Chinese Zodiac, known as Sheng Xiao, is based on a twelve-year cycle, each y ...

  9. HDU 5703 Desert 水题 找规律

    已知有n个单位的水,问有几种方式把这些水喝完,每天至少喝1个单位的水,而且每天喝的水的单位为整数.看上去挺复杂要跑循环,但其实上,列举几种情况之后就会发现是找规律的题了= =都是2的n-1次方,而且这 ...

随机推荐

  1. 虚拟机安装oracle重新启动后oracle em起不来 ORA-01034: ORACLE not available

    (转)http://zhidao.baidu.com/link?url=hM74OA-oWNGGx6RcDaGBwB8Hs0bAnVeKxpC6gpoCGtIGJZ8duYcC-YJ1WNCF7lkP ...

  2. javascript的变量类型:var、let、const

    不同点:可变性,与作用域的关系. 可变性:const定义的变量都不可变,而var和let可以任意更改. const 只能在声明时被初始化一次,之后不允许将全新的值赋值给const变量.但可以修改con ...

  3. CentOS6.2网卡绑定配置

    下面主要介绍在CentOS6.2下使用系统自带的bonding进行网卡绑定的详细步骤,在此之前你可以看一下Linux网卡绑定探析,你也可以使用网卡绑定的脚本进行网卡绑定操作. 注意:请在配置前关闭Ne ...

  4. HapMap

    HapMap五周年回顾 2011-01-12 | 作者: [关闭] 作者简介:曾长青,中国科学院北京基因组所研究员,博士生导师.CUSBEA奖学金.百人计划.杰出青年基金.首批新世纪百千万人才工程国家 ...

  5. CH6802 車的放置

    原题链接 和棋盘覆盖(题解)差不多. 将行和列看成\(n+m\)个节点,且分属两个集合,如果某个节点没有被禁止,则行坐标对应节点向列坐标对应节点连边,然后就是求二分图最大匹配了. #include&l ...

  6. Creating Your Own PHP Helper Functions In Laravel

    By Hamza Ali LAST UPDATED AUG 26, 2018  12,669 104 Laravel provides us with many built-in helper fun ...

  7. nginx域名转发 负载均衡 反向代理

    公司有三台机器在机房,因为IP不够用,肯定要分出来,所以要建立单IP 多域名的反向代理, 就是当请求www.abc.com 跳转到本机, 请求www.bbc.com 跳转到192.168.0.35 机 ...

  8. nginx fastcgi负载均衡

    当后端某机器无法连接,或者处理fastcgi请求时异常退出,nginx会将fastcgi请求发送到另外一台机器. 配置文件 http { include mime.types; default_typ ...

  9. random库的常见用法

    import random print( random.randint(1,10) ) # 产生 1 到 10 的一个整数型随机数 print( random.random() ) # 产生 0 到 ...

  10. tensorflow下识别手写数字基于MLP网络

    # coding: utf-8 # In[1]: import tensorflow as tf import tensorflow.examples.tutorials.mnist.input_da ...