HDU2144Evolution (query set + brute force or LCS)

Source: Internet
Author: User

HDU2144Evolution (query set + brute force or LCS)
EvolutionTime 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 nucleus otide 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 recommend 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 'texceed 100.

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

Sample Input

3 10.0AAAAACCC

Sample Output
Case 1:2
#include
 
  #include
  
   const int N = 105;int fath[N],ins[N],n;void init(){    for(int i=0;i
   
    0)    {        for(int i=0;i
    
     maxlen)                        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
     
      

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.