Naeioi

量子の風
随笔 - 8, 文章 - 0, 评论 - 0, 引用 - 0
数据加载中……

UVa 644

这道题交了4遍才AC,也不懂是什么原因
#include <cstdio>
#include <string.h>
using namespace std;

const int maxn=20;
char a[maxn][maxn],tmp[maxn];
int tot=-1,count=0;

int main()
{
#ifndef ONLINE_JUDGE
    freopen("644.in","r",stdin);
    freopen("644.out","w",stdout);
#endif


    while (scanf("%s",a[++tot])==1)
    {
        if (a[tot][0]!='9')continue;
        bool is=true;
        --tot;
        for (int i=0; i<=tot&&is; i++)
            for (int j=0; j<=tot&&is; j++)
                if (i!=j&&strlen(a[j])>=strlen(a[i]))
                {
                    sprintf(tmp,"%.*s",strlen(a[i]),a[j]);
                    if (strcmp(tmp,a[i])==0)
                        is=false;
                }
        printf("Set %d is ",++count);
        if (is)
            printf("immediately decodable\n");
        else printf("not immediately decodable\n");
        tot=-1;
    }

    fclose(stdin);
    fclose(stdout);
    return 0;
}

posted on 2010-11-12 20:32 Naeioi Zhu 阅读(267) 评论(0)  编辑 收藏 引用 所属分类: 题库题解


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理