程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> 關於C++ >> HDU2144Evolution(並查集+暴力或LCS)

HDU2144Evolution(並查集+暴力或LCS)

編輯:關於C++

Evolution

Time Limit: 20000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 598 Accepted Submission(s): 143


Problem Description Every kind of living creatures has a kind of DNA. The nucleotide bases from which DNA is built are A (adenine), C (cytosine), G (guanine), and T (thymine). Sometimes if two DNA of two living creatures have the same substring, and the length is beyond a certain percentage of the whole length, we many consider whether the two living creatures have the same ancestor. And we can separate them into a certain species temporarily for our research, and we say the two living creatures are similar Make sure if A is similar with B, and B is similar with C, but C is not similar with A, we also separate A, B and C into a kind, for during the evolution, there happens aberrance.
Now we have some kinds of living creatures and their DNA, just tell us how many kinds of living creatures we can separate.

Input There are a lot of cases. In each case, in the first line there are two numbers N and P. N means the number of kinds of living creatures. If two DNA are similar, there exist a substring, and its length is beyond the percentage of any DNA of the two, and P is just the percentage. And 1<=N<=100, and 1<=P<100 (P is 100, which means two DNA are similar if and only if they are the same, so we make sure P is smaller than 100). The length of each DNA won't exceed 100.

Output For each case, just print how many kinds living creatures we can separate.

Sample Input
3 10.0
AAA
AA
CCC

Sample Output
Case 1:
2
#include
#include
const int N = 105;

int fath[N],ins[N],n;

void init()
{
    for(int i=0;i0)
    {
        for(int i=0;imaxlen)
                        maxlen=ii-ti;
                    if(100*maxlen/(len[i]*1.0)>P&&100*(maxlen/(len[j]*1.0))>P)
                            setfath(i,j),flag=1;
                    if(flag)break;
                }
                if(flag)break;
            }
        }
        int k=0;
        for(int i=0;i

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved