zoukankan      html  css  js  c++  java
  • sicily 1035 DNA Matching

     DNA碱基配对,只需要注意配对过的DNA单链不能再配对了,然后就直接按题意做就行了!
    1
    #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 5 using namespace std; 6 7 char s[105][105]; 8 bool used[105]; 9 10 bool is_pair(char s1[], char s2[]) 11 { 12 int len = strlen(s1); 13 for(int i=0; i<len; i++) 14 { 15 if(s1[i] == 'A' && s2[i] != 'T') 16 return 0; 17 if(s1[i] == 'T' && s2[i] != 'A') 18 return 0; 19 if(s1[i] == 'C' && s2[i] != 'G') 20 return 0; 21 if(s1[i] == 'G' && s2[i] != 'C') 22 return 0; 23 } 24 return 1; 25 } 26 27 int main() 28 { 29 int t; 30 scanf("%d", &t); 31 while(t--) 32 { 33 memset(used, 0, sizeof(used)); 34 int count=0; 35 int n; 36 scanf("%d", &n); 37 for(int i=0; i<n; i++) 38 scanf("%s", s[i]); 39 for(int i=0; i<n; i++) 40 for(int j=i+1; j<n; j++) 41 { 42 if(strlen(s[i]) != strlen(s[j])) 43 continue; 44 //for(int k=0; k<strlen(s[i]); k++) 45 if(is_pair(s[i], s[j]) && !used[i] && !used[j]) //注意匹配过的单链不能再用了 46 { 47 count++; 48 used[i]=1; 49 used[j]=1; 50 } 51 52 } 53 cout << count << endl; 54 } 55 return 0; 56 }
  • 相关阅读:
    Server 对象
    Response 对象
    bzoj 5252: [2018多省省队联测]林克卡特树
    bzoj 2167: 公交车站
    bzoj 5315: [Jsoi2018]防御网络
    bzoj 5319: [Jsoi2018]军训列队
    bzoj 4161: Shlw loves matrixI
    bzoj 4942: [Noi2017]整数
    bzoj 2648: SJY摆棋子
    kd-tree 小结
  • 原文地址:https://www.cnblogs.com/dominjune/p/4355537.html
Copyright © 2011-2022 走看看