关于Java的题解,也许效率低下,但是能解决不只是ACGT的序列字符串

代码如下:

 import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
TreeMap<Integer,String> map = new TreeMap<Integer,String>();
//读入题目所给的信息
int n = sc.nextInt(),m = sc.nextInt(),count;
String[] strs = new String[m];
for(int i=0;i<strs.length;i++){
strs[i] = sc.next();
if(strs[i].length()!=n)
throw new RuntimeException();
}
//计算每一个序列的measure数,用count表示
for(int i=0;i<strs.length;i++){
count=0;
for(int j=0;j<strs[i].length()-1;j++){
for(int k=j+1;k<strs[i].length();k++){
char ch1 = strs[i].charAt(j);
char ch2 = strs[i].charAt(k);
if(ch1>ch2)
count++;
}
}
//如果发现序列中有相同的count,那么把该序列加到原序列的末尾,用来最后的输出
if(map.containsKey(count)){
String value = map.get(count);
map.put(count,value+strs[i]);
}
else
map.put(count, strs[i]);
}
//输出答案序列
for(Map.Entry<Integer, String> entry : map.entrySet()){
String value = entry.getValue();
int size = value.length()/n;
if(size>1){
int offset = 0;
for(int i=1;i<=size;i++){
System.out.println(value.substring(offset,offset+n));
offset+=n;
}
}
else
System.out.println(value);
}
}
}

poj 107 DNA sorting的更多相关文章

  1. [POJ 1007] DNA Sorting C++解题

        DNA Sorting Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 77786   Accepted: 31201 ...

  2. poj 1007:DNA Sorting(水题,字符串逆序数排序)

    DNA Sorting Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 80832   Accepted: 32533 Des ...

  3. [POJ] #1007# DNA Sorting : 桶排序

    一. 题目 DNA Sorting Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 95052   Accepted: 382 ...

  4. poj 1007 DNA Sorting

    DNA Sorting Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 95437   Accepted: 38399 Des ...

  5. poj 1007 DNA sorting (qsort)

    DNA Sorting Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 95209   Accepted: 38311 Des ...

  6. poj 1007 DNA Sorting 解题报告

    题目链接:http://poj.org/problem?id=1007 本题属于字符串排序问题.思路很简单,把每行的字符串和该行字符串统计出的字母逆序的总和看成一个结构体.最后把全部行按照这个总和从小 ...

  7. POJ 1007 DNA Sorting(sort函数的使用)

    Description One measure of ``unsortedness'' in a sequence is the number of pairs of entries that are ...

  8. POJ 1007 DNA sorting (关于字符串和排序的水题)

    #include<iostream>//写字符串的题目可以用这种方式:str[i][j] &str[i] using namespace std; int main() {int ...

  9. DNA Sorting 分类: POJ 2015-06-23 20:24 9人阅读 评论(0) 收藏

    DNA Sorting Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 88690 Accepted: 35644 Descrip ...

随机推荐

  1. PythonQt进阶

    本文介绍PythonQt和qt之间是如何进行交互操作的 例子是以Qt的TreeView为实例进行介绍 在该例子中,TreeItem不是从Qt中进行的继承,这样的类如果要和Python进行交互,首先需要 ...

  2. OpenGLES.APPLE_texture_format_BGRA8888

    OpenGL ES的扩展: APPLE_texture_format_BGRA8888 http://www.khronos.org/registry/gles/extensions/APPLE/AP ...

  3. illumina SBS测序详解

    illumina SBS测序详解 2018年01月02日 09:33:56 sixu_9days 阅读数:9789 标签: 生物信息学二代测序 更多 个人分类: 测序原理   最近回头重新看了illl ...

  4. vue-router2.0 初学--动态赋值

    A:router路由配置 1 export default new Router({ 2 routes: [ 3 { 4 path: '/home', 5 name: 'Home', 6 compon ...

  5. NAND FLASH和LCD电路图

  6. 2018.07.13 [HNOI2015]落忆枫音(容斥原理+dp)

    洛谷的传送门 bzoj的传送门 题意简述:在DAG中增加一条有向边,然后询问新图中一共 有多少个不同的子图为"树形图". 解法:容斥原理+dp,先考虑没有环的情况,经过尝试不难发现 ...

  7. CentOS7查看网络的相关命令

    转载自:https://www.linuxidc.com/Linux/2015-07/119555.htm 1.切换到超级用户 [Oscar@localhost 桌面]$ su root 2.查询可用 ...

  8. MySQL外键使用及说明详解

    一.外键约束 MySQL通过外键约束来保证表与表之间的数据的完整性和准确性. 外键的使用条件: 1.两个表必须是InnoDB表,MyISAM表暂时不支持外键(据说以后的版本有可能支持,但至少目前不支持 ...

  9. (KMP Next的运用) Period II -- fzu -- 1901

    http://acm.fzu.edu.cn/problem.php?pid=1901 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=703 ...

  10. Oracle财务系统常用标准报表

    http://erpoperator.blog.163.com/blog/static/17899637220111181121616/ Oracle财务系统常用标准报表 总账系统 系统报表名 中文译 ...