zoukankan      html  css  js  c++  java
  • PC10303/UVA10252

    一开始看错题啦,以为是最长公共字序列的变题,认真一看,原来是排列后的最长公共序列,本来想着排序后,从小到大共同就输出的,但是认真一想,根本没必要,我有bitmap啊!之后哗啦啦地码完了,发现一个神奇的事情,就是WA了,毫不怀疑自己,看了一下别人写的代码,思路基本一样,关键就是都去字符串的时候……UVA/PC很多时候都要getline(cin,str)整行读起……改了一下,马上SOLVED了。。。!!!

    /*******************************************************************************/
    /* OS           : 3.2.0-58-generic #88-Ubuntu SMP Tue Dec 3 UTC 2013 GNU/Linux
     * Compiler     : g++ (GCC)  4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
     * Encoding     : UTF8
     * Date         : 2014-03-30
     * All Rights Reserved by yaolong.
    *****************************************************************************/
    /* Description: ***************************************************************
    *****************************************************************************/
    /* Analysis: ******************************************************************
    *****************************************************************************/
    /*****************************************************************************/
    
    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<string>
    #include<cmath>
    using namespace std;
    #define N 27
    
    int A[N],B[N];
    
    int main(){
    
        int lenA,lenB;
        string strA,strB;
        int i;
        while(getline(cin,strA)&&getline(cin,strB)){
           lenA=strA.length();
           lenB=strB.length();
           memset(A,0,sizeof(A));
           memset(B,0,sizeof(B));
           for(i=0;i<lenA;i++){
               A[strA[i]-'a']++;
            }
            for(i=0;i<lenB;i++){
              B[strB[i]-'a']++;
            }
            for(i=0;i<26;i++){
    
                   int tmp=min(A[i],B[i]);
                    while(tmp--){
                      cout<<char(i+'a');
                    }
            }
            cout<<endl;
    
    
    
    
    
        }
    
    
    
    
    
    
        return 0;
    
    }
    
    
    


  • 相关阅读:
    均匀分布的随机数
    第三十四章 软件工艺的话题
    第三十三章 个人性格
    MySQL常用命令(三)---最值的搜索
    lnmp环境运行laravel open_basedir restriction in effect 问题
    Host 'XXX' is not allowed to connect to this MySQL server解决方案
    CentOS 7中设置PHP7的Log文件日志
    如何查看Laravel版本号的三种方法
    CentOS 7下安装Composer + Laravel
    LNMP一键安装包
  • 原文地址:https://www.cnblogs.com/dengyaolong/p/3697208.html
Copyright © 2011-2022 走看看