标签:style blog http color os io 2014 代码
题意:给定一个文本,如果是{}之间,有几个|就有几个表示方式,如果是$$之间,有连续几个空格,就有空格+1总表示方式,问总的表示方式
思路:模拟,遇到{}就乘上|个数+1,遇到$$就乘上每段空格的个数+1,注意过程中爆long long的,所以达到上限就不再乘了
代码:
#include <cstdio> #include <cstring> typedef long long ll; int cnt, n; ll ans; char c; int main() { while (~scanf("%d%*c", &n)) { cnt = 0; ans = 1; while (cnt < n) { c = getchar(); while (c == '\n') { cnt++; if (cnt == n) break; c = getchar(); } if (c == '{') { ll tmp = 1; while (c != '}') { c = getchar(); while (c == '\n') { cnt++; c = getchar(); } if (c == '|') tmp++; } if (ans <= 100000) ans *= tmp; } else if (c == '$') { ll tmp = 1; c = getchar(); while (c == '\n') { cnt++; c = getchar(); } while (c != '$') { if (c == ' ') { tmp++; } else { if (ans <= 100000) ans *= tmp; tmp = 1; } c = getchar(); while (c == '\n') { cnt++; c = getchar(); } } if (ans <= 100000) ans *= tmp; } } if (ans <= 100000) printf("%lld\n", ans); else printf("doge\n"); } return 0; }
HDU 4891 The Great Pan(模拟),布布扣,bubuko.com
标签:style blog http color os io 2014 代码
原文地址:http://blog.csdn.net/accelerator_/article/details/38276417