uvaoj 620 - Cellular Structure(题意好难理解)

来源:互联网 发布:程序员工作特长 编辑:程序博客网 时间:2024/05/17 13:11
620 - Cellular Structure(题意好难理解)
给了一个细胞链,细胞只有A和B两种,细胞链有几种生长的方式,看看给定的一个细胞链是否是通过这几种方式得到的,要求给出现在所处的状态。
我刚开始也是这样想的,但是没想到偶数就直接是最后一种情况,看了看网上的代码,不过还是有点儿懵。
代码如下:
/*************************************************************************> File Name: 620.cpp> Author: gwq> Mail: gwq5210@qq.com > Created Time: 2014年12月19日 星期五 22时07分24秒 ************************************************************************/#include <cmath>#include <ctime>#include <cctype>#include <climits>#include <cstdio>#include <cstdlib>#include <cstring>#include <map>#include <set>#include <queue>#include <stack>#include <string>#include <vector>#include <sstream>#include <iostream>#include <algorithm>#define INF (INT_MAX / 10)#define clr(arr, val) memset(arr, val, sizeof(arr))#define pb push_back#define sz(a) ((int)(a).size())using namespace std;typedef set<int> si;typedef vector<int> vi;typedef map<int, int> mii;typedef long long ll;const double esp = 1e-5;#define N 10000char str[N];char ans[][20] = {"SIMPLE", "FULLY-GROWN", "MUTAGENIC", "MUTANT"};int main(int argc, char *argv[]){int t;scanf("%d", &t);while (t--) {scanf("%s", str);int len = strlen(str);if (len % 2 == 0) {printf("%s\n", ans[3]);continue;}if (len == 1 && str[0] == 'A') {printf("%s\n", ans[0]);} else if (len >= 2 && str[len - 2] == 'A' && str[len - 1] == 'B') {printf("%s\n", ans[1]);} else if (str[0] == 'B' && str[len - 1] == 'A') {printf("%s\n", ans[2]);} else {printf("%s\n", ans[3]);}}return 0;}


0 0