这道题重点在于理解题意,不是动态规划?(If an organism were in two stages of growth at the same time the first option from the list above should be given as an answer.):
初始阶段微生物为A,有两种生长方式,一种是右边扩展“AB”,一种是最前面扩展“A”而最后面扩展“B”3;
所以合法的微生物的长度都是奇数,然后再判断是否是以上三种阶段即可;
参考了网上的分析。
1 # include <stdio.h> 2 # include <string.h> 3 4 const char s[4][15] = {"SIMPLE","FULLY-GROWN", "MUTAGENIC", "MUTANT"}; 5 6 char org[1005]; 7 8 int main() 9 { 10 int T, i, len; 11 12 scanf("%d", &T); 13 for (i = 1; i <= T; ++i) 14 { 15 scanf("%s", org); 16 len = strlen(org); 17 if ((len&0x1) == 0) puts(s[3]); 18 else if (len == 1 && org[0] == 'A') puts(s[0]); 19 else if (len == 1 && org[0] == 'B') puts(s[3]); 20 else if (strcmp(org+len-2, "AB") == 0) puts(s[1]); 21 else if (org[0] == 'B' && org[len-1] == 'A') puts(s[2]); 22 else puts(s[3]); 23 } 24 25 return 0; 26 }