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. (转)DataRow的各种状态和DataView的两种过滤属性

    DataRow的各种状态 http://www.cnblogs.com/zxjyuan/archive/2008/08/20/1271987.html 一个DataRow对象刚被创建之后(DataTa ...

  2. 前端面试问题js汇总

    1.javascript的typeof返回哪些数据类型 Object number function boolean underfind 2,数组方法pop() push() unshift()shi ...

  3. iOS.Library.Architecture

    在用file查看library的architechture时有以下输出: $ file WebPWebP: Mach-O universal binary with 3 architecturesWe ...

  4. How to use GM MDI interface for programming

    GM has had its newest programming/J2534 Pass Thru device on the market for some years now. A lot has ...

  5. AngularJS 高级程序设计

    1.5.4 安装Web服务器 原来的: connect.static("../angularjs"); 报错.可以修改为: var connect = require('conne ...

  6. 杭电1133 排队买票 catalan

    Buy the Ticket Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)To ...

  7. UI设计师需要熟记的45个快捷键Windows、Mac

    大家都知道PS快捷键很多,其实没必要都记住,今天为大家整理了45个比较实用的,别忘了收藏. 图层 填充图层 MAC: Alt+Backspace (前景) or Cmd+Backspace (背景) ...

  8. python 读取xml

    #!/usr/bin/python # -*- coding: UTF- -*- from xml.dom.minidom import parse import xml.dom.minidom # ...

  9. db2 解锁表

    db2 set integrity for ACT_RU_VARIABLE immediate checked

  10. Windows-universal-samples学习笔记系列四:Data

    Data Blobs Compression Content indexer Form validation (HTML) IndexedDB Logging Serializing and dese ...