2014多校第三场1005 || HDU 4891 The Great Pan(模拟)
2014-07-29 18:33
585 查看
题目链接
题意 : 给你n行字符串,问你有多少种理解方式。有两大类的理解
(1){A|B|C|D|...}代表着理解方式可以是A,可以是B或C或者D。
(2)$blah blah$,在$$这两个符号中间,如果是不连续的空格的那个位置就有2种理解方式,可以理解为没有空格也可以理解为有空格。如果有连续N个空格的位置,那里就有N+1种理解方式。
最后所有的理解方式相乘,数据保证$一定与$匹配,{一定与匹配},不会有任何嵌套,类似{$$}或者{{}}或者${}$这种情况都不会出现,也不会有{$}这种情况,所有的${}这些符号一定有匹配的。
输出多少种理解方式。
思路 : 模拟,但是由于我们在做的时候一直以为数据范围不会超,就一直WA,后来我直接找特殊数据找的恶心,又看了代码觉得没有错,就放弃了,对不起二师兄。。。。。直接贴YN的代码吧,不想写了,恶心
View Code
题意 : 给你n行字符串,问你有多少种理解方式。有两大类的理解
(1){A|B|C|D|...}代表着理解方式可以是A,可以是B或C或者D。
(2)$blah blah$,在$$这两个符号中间,如果是不连续的空格的那个位置就有2种理解方式,可以理解为没有空格也可以理解为有空格。如果有连续N个空格的位置,那里就有N+1种理解方式。
最后所有的理解方式相乘,数据保证$一定与$匹配,{一定与匹配},不会有任何嵌套,类似{$$}或者{{}}或者${}$这种情况都不会出现,也不会有{$}这种情况,所有的${}这些符号一定有匹配的。
输出多少种理解方式。
思路 : 模拟,但是由于我们在做的时候一直以为数据范围不会超,就一直WA,后来我直接找特殊数据找的恶心,又看了代码觉得没有错,就放弃了,对不起二师兄。。。。。直接贴YN的代码吧,不想写了,恶心
#include <stdio.h> #include <string.h> #include <iostream> #include <algorithm> #include <vector> #include <queue> #include <set> #include <map> #include <string> #include <math.h> #include <stdlib.h> #define clear(A, X, SIZE) memset(A, X, sizeof(A[0]) * (SIZE)) #define clearall(A, X) memset(A, X, sizeof(A)) #define max( x, y ) ( ((x) > (y)) ? (x) : (y) ) #define min( x, y ) ( ((x) < (y)) ? (x) : (y) ) using namespace std; int main() { // freopen("data1.txt","r",stdin); int n,temp,cnt; long long ans ; char c,x; while(scanf("%d",&n)!=EOF) { x = getchar(); while(x != '\n') x = getchar() ; bool flat1 = false , flat2 = false , flat = true ; ans = 1 ; temp = 1 ; while(n--) { c = getchar(); while(c != '\n') { if(flat) { if(ans > 100000 || temp > 100000) { ans = 1000000; flat = false; continue; } if(c == '{') { flat1 = true ; cnt = 1 ; } else if(c == '}') { ans *= cnt ; flat1 = false; } else if(flat1 && c == '|') { cnt ++ ; } else if(!flat2 && c == '$') { flat2 = true ; temp = 1 ; cnt = 1 ; } else if(flat2 && c == '$') { temp *= cnt; ans *= temp; flat2 = false; } else if(flat2 && c == ' ') { cnt ++ ; } else if(flat2 && c != ' ') { temp *= cnt ; cnt = 1 ; } } c = getchar(); } } if(ans > 100000) puts("doge"); else printf("%I64d\n",ans); } return 0; }
View Code
相关文章推荐
- hdu 4891 The Great Pan (模拟)
- hdu 4891 The Great Pan(模拟)
- HDU 4891 The Great Pan(模拟)
- 【HDU 4891 多校联合】The Great Pan【模拟】
- HDU 4891 The Great Pan (模拟)
- HDU 4891 The Great Pan(模拟)
- HDU 4891 The Great Pan (模拟)
- hdu 4891 The Great Pan(模拟)
- hdu 4891 The Great Pan 2014多校联合第三场
- HDU 4891 The Great Pan (题意题+模拟)
- HDU 4891 The Great Pan (字符串处理)
- HDU 4891— The Great Pan
- HDU 4891 The Great Pan
- HDU--4891--The Great Pan--暴力搜索
- HDU 4891 The Great Pan 解题报告(水题)
- hdu 4891 The Great Pan
- hdu 4891 The Great Pan
- hdu 4891 The Great Pan
- HDU 4891 The Great Pan
- HDU4891_The Great Pan_字符串水题