hdu 4891 模拟水题
2014-10-21 22:05
176 查看
http://acm.hdu.edu.cn/showproblem.php?pid=4891
给出一个文本,问说有多少种理解方式。
1. $$中间的,(s1+1) * (s2+1) * ...*(sn+1), si表示连续的空格数。
2.{}中间,即 | 的个数+1.
就是模拟
给出一个文本,问说有多少种理解方式。
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 2598 Manipulating the Power Square 模拟水题
- HDU 3635 Dragon Balls 并查集水题 模拟
- HDU 5095 Linearization of the kernel functions in SVM(模拟, 水题)
- HDU 5099 Comparison of Android versions(模拟-水题)
- HDU 1228 模拟水题
- 【HDU 5532 Almost Sorted Array】水题,模拟
- hdu 5003 模拟水题
- HDU 1736(字符串模拟的水题)
- HDU 5186 zhx's submissions 模拟水题
- 2014多校第三场1005 || HDU 4891 The Great Pan(模拟)
- hdu 4891 The Great Pan (模拟)
- hdu 4891 The Great Pan(模拟)
- hdu 5003 模拟水题
- HDU 4891 The Great Pan(模拟)
- hdu 4530 小Q系列故事——大笨钟 模拟水题
- HDU 4891 The Great Pan(模拟)
- HDU 4891 The Great Pan 解题报告(水题)
- hdu 5083 有坑+字符串模拟水题
- HDU 4891 The Great Pan (模拟)