您的位置:首页 > 其它

nyoj 17 最长子序列相关问题

2016-08-06 21:04 190 查看
#include<stdio.h>
#include<string.h>
int main()
{
int T,count;
char a[10000],dp[30];
scanf("%d",&T);
while(T--)
{
count=0;
memset(dp,0,sizeof(dp));
scanf("%s",a);
int len=strlen(a);
for(int i=0;i<len;i++)
{
for(int j=count;j>=0;j--)
{
if(a[i]>dp[j])
{
dp[j+1]=a[i];
if(j==count)
count++;
break;
}
}
}
printf("%d\n",count);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: