zoukankan      html  css  js  c++  java
  • UVA 620 Cellular Structure

    读了几遍题,还不知道题的意思,唉,理解能力啊,看了别人的代码之后,奥,原来是这样,这里简单说一下对题目的理解,它说我们有这样一个细胞链,其中细胞只有A和B两种,给你这个细胞链让你看一下,是不是经过所给的三种状态,可以变化成现在的状态,然后输出现在处于什么状态。的确像个DPS。

    代码如下:

    #include<stdio.h>
    #include<string.h>
    #define MAXN 100100
    int n, stage;
    char c[MAXN];
    char t[4][20] = {"SIMPLE","FULLY-GROWN","MUTAGENIC","MUTANT"};
    void dp(int head, int last, int flag)
    {
    if(head == last)
    {
    if(c[head] == 'A')
    {
    if(flag)
    stage = 1, flag = 0;
    }
    else stage = 4;
    }
    else if(last - head >= 2)
    {
    if(c[last] == 'B'&&c[last-1] == 'A')
    {
    if(flag)
    stage = 2, flag = 0;
    dp(head, last-2,flag);
    }
    else if(c[head] == 'B' && c[last] == 'A')
    {
    if(flag)
    stage = 3, flag = 0;
    dp(head+1, last-1,flag);
    }
    else stage = 4;
    }
    else stage = 4;
    }
    void input()
    {
    while(scanf("%d",&n) == 1)
    for(int i = 0; i < n; i ++)
    {
    scanf("%s", c);
    int len = strlen(c);
    int rear = len - 1;
    int first = 0;
    dp(first,rear,1);
    printf("%s\n",t[stage-1]);
    }
    }
    int main()
    {
    input();
    return 0;
    }
  • 相关阅读:
    hdu 1106 排序(排序)
    hdu 1040 As Easy As A+B(排序)
    hdu 1029 Ignatius and the Princess IV(排序)
    mysql-9索引
    mysql-8 alter命令
    mysql-7事务管理
    mysql-6正则表达式
    http协议
    9-2交互体验
    9-2专项测试下午
  • 原文地址:https://www.cnblogs.com/yuzhaoxin/p/2412440.html
Copyright © 2011-2022 走看看