Describe
DNA (deoxyribonucleic acid) is a medium for storing genetic information in the human body. A nucleotide is a polymer chain made up of subunits that are arranged together. The DNA polymer chain is also called the DNA line.
The nucleotide genes in DNA can be divided into four types depending on the chemical composition or method of acquisition: Adenine,guanine, cytosine and thymine, respectively, in A,g,c and T. A single nucleotide is linked into DNA by end-to-end chemical behavior, which simply says that we can act on a series of a,t,c and G-composed strings that represent a chain, such as ATTCGAC, but we should note that the nucleotide consists of a string with directionality, so we think ATTCGAC and Cagctta represent two different chains.
Genes usually do not exist in the form of a free single strand. Under appropriate conditions the single strand will appear in pairs, and around each other, forming the famous double helix structure. This pairing appears in as with Ts,gs and TS, because they are attracted to each other and are called hydrogen bonds. Therefore, A/T and g/c are called complementary base pairs.
The Molecular Biological Laboratory is a DNA experiment, and one of the important tasks is to make DNA double-strand by matching two base pairs of wires. We require two single-base pairs to have the same length, requiring two nucleotide genes in the same position in a single strand to be complementary base pairs. For example ATTCGAC and TAAGCTG are complementary, but Cagctta and TAAGCTG are not, ATTCGAC and GTAAGCT are not.
As an assistant to biological research, your boss gives you a task: given n single-strand, find out the maximum number of pairs that can be paired (of course, each single chain is used up to one time only). If n is very small, it can be easily written calculation out, but when n is large, it is not. It is now required to use the authoring program implementation.
Input
The input includes multiple test cases, and the first line is a positive integer T (t<=20), which indicates the number of test cases. In each test case, the first line is a positive integer n (n<=10000), which represents the number of single chains. The next n rows, each line represents a single chain. The length of each single strand does not exceed 1000
Output
For each test case, one line is used to output an integer, which is the maximum number of double chains that can be paired.
Sample input
2
3
Atcg
Tagc
Tagg
2
Aatt
ATTA
Sample output
1
0
#include <iostream>#include<cstdio>#include<cstring>using namespacestd;Chara[10001][1010];intMain () {intN, M, I, J; BOOLuse[100010]; CIN>>N; while(n--) {memset (use,true,sizeofUse ); CIN>>m; intsum =0; GetChar (); for(i=0; I < m; i++) gets (A[i]); for(i =0; I < M1; i++) { for(j =0; a[i][j]!=' /'; J + +) { if(A[i][j] = ='T') A[i][j]='A'; Else if(A[i][j] = ='A') A[i][j]='T'; Else if(A[i][j] = ='C') A[i][j]='G'; Else if(A[i][j] = ='G') A[i][j]='C'; } for(j = i+1; J < M; J + +) { if(strcmp (a[i],a[j]) = =0&& Use[i] &&Use[j]) {Sum++; Use[i]=false; USE[J]=false; } }} cout<<sum<<Endl; } return 0;}
DNA matching problem