一开始看错题啦,以为是最长公共字序列的变题,认真一看,原来是排列后的最长公共序列,本来想着排序后,从小到大共同就输出的,但是认真一想,根本没必要,我有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; }

PC10303/UVA10252的更多相关文章

随机推荐

  1. Unity给力插件之Final IK

    Final IK细节: 1.Aim IK:设定一个目标,关节末端始终朝向该目标,一般用来做头部的朝向. 步骤: a.在模型头节点处添加Aim空物体并reset b.给模型添加Aim IK组件,并填上A ...

  2. Java web.xml加载顺序

     web.xml加载过程(步骤): 1.启动WEB项目的时候,容器(如:Tomcat)会去读它的配置文件web.xml.读两个节点:   <listener></listener&g ...

  3. 基于TCP协议的客户端

    基于TCP协议的客户端 此客户端能用于下一篇博客的单线程服务器和多线程服务器 import java.io.BufferedReader; import java.io.IOException; im ...

  4. hdoj 2401 Baskets of Gold Coins

    Baskets of Gold Coins Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

  5. Y2K Accounting Bug

    题目: Description Accounting for Computer Machinists (ACM) has sufferred from the Y2K bug and lost som ...

  6. (7/18)重学Standford_iOS7开发_视图、绘制、手势识别_课程笔记

    第七课: 1.View 一般来说,视图是一个构造块,代表屏幕上一块矩形区域,定义了一个坐标空间,并在其中绘制及添加触控事件等. ①视图的层级关系 一个视图只能有一个父视图,可以有多个子视图 - ( - ...

  7. 在Mybatis-spring中由于默认Autowired导致不能配置多个数据源的问题分析及解决

    在使用Mybatis中,通常使用接口来表示一个Sql Mapper的接口以及相对应的xml实现,而在spring的配置文件中,通常会使用MapperScannerConfigurer来达到批量扫描以及 ...

  8. 【转】国内较快的maven镜像

    国内连接maven官方的仓库更新依赖库,网速一般很慢,收集一些国内快速的maven仓库镜像以备用. ====================国内OSChina提供的镜像,非常不错=========== ...

  9. java 图片压缩 剪切 水印 转换 黑白 缩放

    专注java已6年,欢迎加入java核心技术QQ群:135138817,每周五晚有群主进行技术讲座. import java.awt.AlphaComposite; import java.awt.C ...

  10. Bootstrap-基于jquery的bootstrap在线文本编辑器插件Summernote

    Summernote是一个基于jquery的bootstrap超级简单WYSIWYG在线编辑器.Summernote非常的轻量级,大小只有30KB,支持Safari,Chrome,Firefox.Op ...