日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

UVa 1368 - DNA Consensus String

發布時間:2024/4/13 编程问答 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 UVa 1368 - DNA Consensus String 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

這是連續第8次1Y了,哈哈哈,不過,不過這題看起來挺嚇人,讀完才知道就是讓球一個目標DNA序列,和每個所給序列最相近。不是從里面選,第一次就是這么理解的然后。。。。。是自己用A C G T中組合。如果有多解選字典序最小的。

題目定位 : 字符串水題。 貌似有點貪心的意思。

上Java代碼 :

import java.util.*;public class Main {public static void main(String[] args) {Scanner scan = new Scanner(System.in);int t = scan.nextInt();while(t-- > 0) {int m = scan.nextInt();int n = scan.nextInt();StringBuilder sb = new StringBuilder();String s;DNA[] dna = new DNA[m + 1];for(int i=0; i<m; i++) {s = scan.next();dna[i] = new DNA(s, 0);}int[] cnt = new int[4];int dis = 0;for(int j=0; j<n; j++) {Arrays.fill(cnt, 0);for(int i=0; i<m; i++) {if(dna[i].str.charAt(j) == 'A') {cnt[0] ++;}if(dna[i].str.charAt(j) == 'C') {cnt[1] ++;}if(dna[i].str.charAt(j) == 'G') {cnt[2] ++;}if(dna[i].str.charAt(j) == 'T') {cnt[3] ++;}}int max = cnt[0];char ch = 'A';for(int k=1; k<4; k++) {if(cnt[k] > max) {max = cnt[k];if(k == 1) {ch = 'C';}if(k == 2) {ch = 'G';}if(k == 3) {ch = 'T';}}}if(ch == 'A') {dis += cnt[1] + cnt[2] + cnt[3];}if(ch == 'C') {dis += cnt[0] + cnt[2] + cnt[3];}if(ch == 'G') {dis += cnt[0] + cnt[1] + cnt[3];}if(ch == 'T') {dis += cnt[1] + cnt[2] + cnt[0];}sb.append(ch);}System.out.println(sb);System.out.println(dis);}}} class DNA {public String str;public int cnt;public DNA(String str, int cnt) {this.str = new String(str);this.cnt = cnt;} }


?

?

轉載于:https://www.cnblogs.com/wxisme/p/4363741.html

總結

以上是生活随笔為你收集整理的UVa 1368 - DNA Consensus String的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。