UVa 1584 - Circular Sequence

原创 2015年11月19日 09:52:33

題目:給你一個基因串構成的環,可以再人和位置切開,問切開后的最小字典序串。

分析:字符串,簡單題。直接枚舉所有的串,求最小的即可。

說明:╮(╯▽╰)╭。

#include <cstring>
#include <cstdio>

char buf[101];
char map[101][101];

int main()
{
	int n;
	while (~scanf("%d",&n))
	while (n --) {
		scanf("%s",buf);
		int l = strlen(buf);
		memset(map, 0, sizeof(map));
		for (int i = 0; i < l; ++ i)
			for (int j = 0; j < l; ++ j)
				map[i][j] = buf[(i+j)%l];
		int index = 0;
		for (int i = 1; i < l; ++ i)
			if (strcmp(map[index], map[i]) > 0)
				index = i;
		puts(map[index]);
	}
	return 0;
}


版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

UVA 1584

Description Some DNA sequences exist in circular forms as in the following figure, which shows ...

UVa 1584 Circular Sequence 【数组和字符串】

Time limit: 3.000 seconds Description Some DNA sequences exist in circular forms as in the following...

UVA1584 UVALive3225 Circular Sequence

Regionals 2004 >> Asia - Seoul 问题链接:UVA1584 UVALive3225 Circular Sequence。基础训练级的题,用C语言编写。 这个问题是寻找循环...

UVA-1584 Circular Sequence

Some DNA sequences exist in circular forms as in the following figure, which shows a circular sequenc...

环装序列 (Circular Sequence, ACM/ICPC Seoul 2004, UVa1584)

长度为n的环状串有n种表示法,分别为某个位置开始顺时针得到。例如,图中的环状串有10种表示: CGAGTCAGCT,GAGTCAGCTC,AGTCAGCTCG等。在这些表示法中,字典序最小的称为...

UVA 1584 Circular Sequence

1584 - Circular Sequence Some DNA sequences exist in circular forms as in the following figure, w...

UVa 1584 - Circular Sequence

Some DNA sequences exist in circular forms as in the following figure, which shows a circular sequen...

UVa 1584 Circular Sequence(循环串 字典序)

每次后移一位比较字典序即可  注意不能用strcpy(s+1,s)

UVa 1584 Circular Sequence / 455 Periodic Strings(枚举字符串)

原题地址https://vjudge.net/problem/UVA-1584 题意:DNA的四个字母CGAT排列成环形,可以移动起点,输出字典序最小的环形序列(顺时针)。 解题思路这道题是《算法...

UVA 1584 Circular Sequence【字典序】

Circular Sequence   Status Description Download as PDF Some DNA sequences exist in circular f...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)