hdu 4891 模拟水题
来源:互联网 发布:c语言中的关键字有哪些 编辑:程序博客网 时间:2024/05/16 12:28
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 100005int 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;}
0 0
- hdu 4891 模拟水题
- HDU 1228 模拟水题
- hdu 5003 模拟水题
- hdu 4891 模拟
- hdu 4452 Running Rabbits(模拟水题)
- HDU 4121 Xiangqi 模拟题(水
- HDU-5835 Danganronpa(模拟水题)
- HDU 3682 水模拟
- hdu 4561 水模拟
- HDU 5373 (模拟 水~)
- hdu 3269 模拟题
- HDU 4770 模拟题
- HDU 4772 模拟题
- hdu 1049 模拟题
- HDU 4930 模拟题
- hdu-1103 模拟题。
- hdu 4770 模拟题
- hdu 4801模拟题
- 工作一年多了,开始blog之旅吧
- C# 枚举使用和对应说明获取实例
- 最大数的4种方法
- MERGE 函数的使用
- POJ 1159Palindrome
- hdu 4891 模拟水题
- 简单分析阿里云生态环境
- 查询语句中select from where group by having order by的执行顺序
- C++基本知识点(读书笔记)
- C和指针 三
- Linux下让SSH/SOCKS成为全局代理 轻松冲浪
- bzoj 1977: [BeiJing2010组队]次小生成树
- 编程珠玑——第一章习题解答
- 漫谈SOA(面向服务架构)