poj 2681 字符串
http://poj.org/problem?id=2681
给你任意长度的字符串,找出两串字符中不相同的字符个数(总数)
#include<string>
#include<cstring>
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int n;
scanf("%d\n",&n);
string aa,bb;
int q=;
for(int i=;i<=n;i++)
{
int sum=;
int a1[]={},b1[]={};
getline(cin,aa);
getline(cin,bb);
//scanf("%s\n%s",aa,bb);
int a=aa.length();
int b=bb.length();
if(a==||b==)
{
cout<<"Case #"<<i<<": "<<max(a,b)<<endl; }
//int sum=0;
else{
for(int k=;k<a;k++)
{
for(int j=;j<b;j++)
{
if(aa[k]==bb[j]&&a1[k]==&&b1[j]==)
{
a1[k]=;
b1[j]=;
}
} } for(int k=;k<a;k++)
{
if(a1[k]==)sum++;
}
for(int j=;j<b;j++)
{
if(b1[j]==)sum++; } cout<<"Case #"<<i<<": "<<sum<<endl;
} } return ;
}
poj 2681 字符串的更多相关文章
- POJ 1200 字符串HASH
题目链接:http://poj.org/problem?id=1200 题意:给定一个字符串,字符串只有NC个不同的字符,问这个字符串所有长度为N的子串有多少个不相同. 思路:字符串HASH,因为只有 ...
- poj 3461 字符串单串匹配--KMP或者字符串HASH
http://poj.org/problem?id=3461 先来一发KMP算法: #include <cstdio> #include <cstring> #include ...
- poj 2503(字符串)
http://poj.org/problem?id=2503 题意:就是翻译,给你一个字典,然后再查找单词,找得到的就输出单词,找不到的输出eh,用Map水题一个,但这个题有点意思的就是输入的问题 # ...
- poj 3981 字符串替换
字符串替换 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10871 Accepted: 5100 Descriptio ...
- poj 2503 字符串hash
题目链接:http://poj.org/problem?id=2503 代码: #include<cstdio> #include<cstring> #include<i ...
- poj 1200字符串hash
题意:给出不同字符个数和子串长度,判断有多少个不同的子串 思路:字符串hash. 用字符串函数+map为什么会超时呢?? 代码: #include <iostream> #include ...
- poj 2774 字符串哈希求最长公共子串
Long Long Message #include <iostream> #include <algorithm> #include <cstdio> #incl ...
- POJ 3080 (字符串水题) Blue Jeans
题意: 找出这些串中最长的公共子串(长度≥3),如果长度相同输出字典序最小的那个. 分析: 用库函数strstr直接查找就好了,用KMP反而是杀鸡用牛刀. #include <cstdio> ...
- POJ 2681
#include<iostream> #include<stdio.h> #include<string> #include<algorithm> #d ...
随机推荐
- 2015最新Android学习线路图
Android是一个以Linux为基础的半开源操作系统,主要用于移动设备,由Google和开放手持设备联盟开发与领导.据2011年初数据显示仅正式上市两年的操作系统Android已经跃居全球最受欢迎的 ...
- CSRF与xss的区别
CSRF:无法获取受害者的cookie,无法看到cookie: 只是利用受害者是被服务器信任的(靠验证cookie),而给服务器发送请求: xss:利用cookie只是xs ...
- 一句Python,一句R︱pandas模块——高级版data.frame
先学了R,最近刚刚上手python,所以想着将python和R结合起来互相对比来更好理解python.最好就是一句python,对应写一句R. pandas可谓如雷贯耳,数据处理神器. 以下符号: = ...
- sdl的缩放问题
SDL是一种既是开源的,也是跨平台的多媒体开发包,在各种平台上应用很广,经常和FFMPEG等解码器同时使用.对于在windows mobile等缺乏通用播放器的平台来说,是一种很好的选择.网上很多代码 ...
- linux下ffmpeg安装
1.ffmpeg下载地址: http://www.ffmpeg.org/download.html 2.解压 1 $ tar zvfj ffmpeg.tar.bz2 这里作者假设已经重命名为ffmpe ...
- PowerManager和PowerManager.WakeLock详解
最近在做项目过程中,有一个LocalPush的需求,需要保持屏幕点亮一段时间,并且在这个时间里,启动Service来执行请求服务器的操作,拿到热点的数据.所以,就找了一下相关的android开源项目. ...
- HighCharts之2D含有负值的面积图
HighCharts之2D含有负值的面积图 1.HighCharts之2D含有负值的面积图源码 AreaNegative.html: <!DOCTYPE html> <html> ...
- 异常-----java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.core.KeyFactory
SSH 类库问题 java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer2009- ...
- C#方法有关内容的总结--C#基础
1.静态方法与实例方法 using System;using System.Collections.Generic;using System.Linq;using System.Text;using ...
- JS实现回到Top(顶部)--JavaScript
当我们浏览一段很长的网页时,已经看到底部了,想回到顶部看前面的内容,可是需要滚动好几转鼠标滑轮或者拉动滚动条走好长“一段路”.这对于用户来说,体验效果是不够好的.如果我们借助简单的一个按钮,点击一下就 ...