uva620 - Cellular Structure
来源:互联网 发布:蓝韵网络 编辑:程序博客网 时间:2024/05/29 08:59
题意:
题目说的天花乱坠,结合样例,大概讲的是,给你一个串,有三种情况:
simple stage O = A
• fully-grown stage O = OAB
• mutagenic stage O = BOA
如果不是这三种情况就是MUTANT
(如A:为简单层,O即为A,
AAB:相当于OAB,O即为A或者AAB
BAABA:相当与BOA,O即为A或者AAB或者BAABA
依次类推…
)
思路:
这里的递推关系不难看出,分成三种情况看当前串能不能满足,只要是能满足,就会成为又一个O,依次类推…
代码如下:
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int N = 105;char str[N];int n;int DP(int i, int j) { if (i == j && str[i] == 'A') return 1; else if (str[j] == 'B'&& str[j-1]=='A'&&j - i >= 2 && DP(i, j - 2)) return 2; else if (str[i] == 'B'&&str[j] == 'A' && j-i>=2 && DP(i+1,j-1)) return 3; return 0;}int main() { scanf("%d", &n); while (n--) { scanf("%s", str); int i = DP(0,strlen(str)-1); if (i == 1) printf("SIMPLE\n"); else if (i == 2) printf("FULLY-GROWN\n"); else if (i == 3) printf("MUTAGENIC\n"); else printf("MUTANT\n"); } return 0;}
0 0
- uva620 - Cellular Structure(....)
- UVA620- Cellular Structure
- uva620 - Cellular Structure
- uva 620 Cellular Structure
- UVA 620 Cellular Structure
- 620 - Cellular Structure
- UVa 620 - Cellular Structure
- uva 620 - Cellular Structure
- UVa 620 - Cellular Structure
- Uva-620-Cellular Structure
- uva 620 Cellular Structure
- uva 620 - Cellular Structure
- UVA - 620 Cellular Structure
- UVa:620 Cellular Structure
- uva 620 Cellular Structure
- UVa Cellular Structure
- UVA - 620 Cellular Structure
- UVA 620 Cellular Structure
- 项目中遇到的问题(一)弹出UIAlertController 时出现 Warning: Attempt to present * on * which is already presenting
- 错误票据 蓝桥杯
- 【LatinIME】默认开启键盘按键声
- 八、Window
- 5-35计算N个分式有理数的平均值
- uva620 - Cellular Structure
- 炮弹攻击
- (1)线性查找和二分搜索
- spring异常:FileNotFoundException: Could not open ServletContext resource [/WEB-INF/XX-servlet.xml
- 原码,补码,反码详解
- 由主线程更新UI所想到的Window和RootViewImpl的创建过程
- hdu4311(排序)
- 203. Remove Linked List Elements
- xcoj 1203 F.铺设电缆