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. web服务器 双网卡 路由 设置

    最近在装服务器的时候,遇到一个问题,就是这个服务器本身是一个web服务器,但它上面装有一个局域网数据交换软件,还需要访局域网. 但软件装上去了,局域网怎么也不能访问,后来了解到是因为双网卡的原因,需要 ...

  2. hdu 3368 曾经下过的棋

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3368 就是讲一种下棋的方法,很多人小时候也应该玩过,输入8*8的矩阵代表棋盘,*代表空位 D代表黑子, ...

  3. fedora 使用

    我们在这篇指南中将介绍安装Fedora 23工作站版本后要完成的一些实用操作,以便用起来更爽. 1.更新Fedora 23程序包 哪怕你可能刚刚安装/升级了Fedora 23,仍很可能会有需要更新的程 ...

  4. 初学者的分布式Python爬虫教程

    下面是一个超级计算机的排行榜,如果我们能拥有其中任意一个,那么我们就不需要搞什么分布式系统.可是我们买不起,即使买得起,也交不起电费,所以我们只好费脑子搞分布式. 分布式的本质就如上期提到的一个概念: ...

  5. 05. pt-diskstats

    pt-diskstats --devices-regex=sda --interval=1 --iterations=3 --show-timestamps #ts device rd_s rd_av ...

  6. swift 总结

    结构体(struct)属于值类型, 当值类型的实例被声明为常量的时候,它的所有属性也就成了常量. 属于引用类型的类(class)则不一样.把一个引用类型的实例赋给一个常量后,仍然可以修改该实例的变量属 ...

  7. 论坛:一对一关联映射/单向关联/两个类间,可以有两个(多个)关联关系/content为大文本类型/

    >>单向:只写一端的映射属性,另一端不写(有一端用不着);双向:两端都写映射属性 >>一对一关联有两类:一类基于主键的(一般不使用),一类基于外键的(重点学习): 外键:是一个 ...

  8. 纯css导航栏下划线

    .nav-underline > *{/* 指定容器,里面可以是li.span等多样化的元素 */ display: inline-block; margin: -3px; padding: 1 ...

  9. 2017/2/5:oracle数据库的三大文件

    oracle的三大文件: 一:控制文件:控制文件是一个小型的二进制文件,可以记录数据库的物理结构.包括:     * 数据库名称     * 数据文件和日志文件的名称和位置     * 数据库创建的时 ...

  10. [cmd]如何设置 Windows 默认命令行窗口大小和缓冲区大小

    Windows 命令行 cmd 窗口系统默认的大小(80*40)对于现在的屏幕配置已经跟不上时代了,我们总是要把它改大些,而且缓冲区大小也想改得大大的.单纯的为当前的 Windows 命令行窗口修改显 ...