//hdu_2717
//map 一对多映射,基于关键字快速查找,不允许重复值
//queue 队列 先进先出 #include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<map>
using namespace std;
struct node{
int x,step;
};
int main(){
int n,m;
while(scanf("%d%d",&n,&m) != EOF ){
queue<node>qu;
map<int,int>mp;
mp.clear();
node ad,tmp;
ad.x=n, ad.step=;
mp[ad.x]=;
qu.push(ad);
while(!qu.empty()){
tmp=qu.front();
qu.pop();
if(tmp.x==m) break;
ad.x=tmp.x+, ad.step=tmp.step+;
if(ad.x>= && ad.x<= && !mp[ad.x]){
mp[ad.x]=;
qu.push(ad);
}
ad.x=tmp.x-, ad.step=tmp.step+;
if(ad.x>= && ad.x<= && !mp[ad.x]){
mp[ad.x]=;
qu.push(ad);
}
ad.x=tmp.x*, ad.step=tmp.step+;
if(ad.x>= && ad.x<= && !mp[ad.x]){
mp[ad.x]=;
qu.push(ad);
}
}
printf("%d\n",tmp.step);
}
system("pause");
} //hdu_1412
//set 快速查找 不允许重复值
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<set>
using namespace std; int main()
{
set<int>st;
set<int>::iterator it;
int n,m,i,j;
int a,b,f;
while(scanf("%d%d",&n,&m)!=EOF)
{
st.clear();
for(i=;i<n;i++)
{
scanf("%d",&a);
st.insert(a);
}
for(j=;j<m;j++)
{
scanf("%d",&b);
st.insert(b);
}
f=;
for(it=st.begin();it!=st.end();it++)
{
if(f)printf(" ");
f=;
printf("%d",*it);
}
printf("\n");
}
}

STL练习题的更多相关文章

  1. STL练习题续

    //zjnu 1399 //sort 数组可用//vector sort(vector) #include<iostream> #include<algorithm> usin ...

  2. Team Queue(STL练习题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1387 Team Queue Time Limit: 2000/1000 MS (Java/Others ...

  3. 【tyvj】刷题记录(1001~1099)(64/99)

    1001:排序完按照题意做即可. #include<cstdio> #include<iostream> #include<cmath> #include<a ...

  4. 洛谷 P1360 [USACO07MAR]Gold Balanced Lineup G (前缀和+思维)

    P1360 [USACO07MAR]Gold Balanced Lineup G (前缀和+思维) 前言 题目链接 本题作为一道Stl练习题来说,还是非常不错的,解决的思维比较巧妙 算是一道不错的题 ...

  5. codevs http://www.codevs.cn/problem/?problemset_id=1 循环、递归、stl复习题

    12.10高一练习题 1.要求: 这周回顾复习的内容是循环.递归.stl. 不要因为题目简单就放弃不做,现在就是练习基础. 2.练习题: (1)循环   题目解析与代码见随笔分类  NOI题库 htt ...

  6. (转载)C++:STL标准入门汇总

    (转载)http://www.cnblogs.com/shiyangxt/archive/2008/09/11/1289493.html 学无止境!!! 第一部分:(参考百度百科) 一.STL简介 S ...

  7. C++ STL标准入门

    C++:STL标准入门汇总 第一部分:(参考百度百科) 一.STL简介 STL(Standard Template Library,标准模板库)是惠普实验室开发的一系列软件的统称.它是由Alexand ...

  8. C++ STL 的初步认知

    学无止境!!!    尊重他人劳动,尊重出处:http://www.cnblogs.com/shiyangxt/archive/2008/09/11/1289493.html 我已经做了4年的MFC ...

  9. 实验8 标准模板库STL

    一.实验目的与要求: 了解标准模板库STL中的容器.迭代器.函数对象和算法等基本概念. 掌握STL,并能应用STL解决实际问题. 二.实验过程: 完成实验8标准模板库STL中练习题,见:http:// ...

随机推荐

  1. 一个的unity学习系列的博客

    1.http://my.csdn.net/caoboya 2.http://my.csdn.net/OnafioO

  2. DOCTYPE的重要性

    <!DOCTYPE>是文档类型声明: 声明必须是 HTML 文档的第一行,位于 <html> 标签之前.明不是 HTML 标签:它是指示 web 浏览器关于页面使用哪个 HTM ...

  3. 网络-->监控-->单位换算

    The metric system In some cases when used to describe data transfer rates bits/bytes are calculated ...

  4. MySQL高级查询语句

    高级查询: 一:多表连接 1.select Info.Code,Info.Name,Nation.Name from Info,Nation where Info.Nation = Nation.Co ...

  5. 今天发现之前瑞乐做的登录和注册居然都是用的get请求,瞬间出了一身冷汗.

    今天发现之前瑞乐做的登录和注册居然都是用的get请求,瞬间出了一身冷汗. 然后迅速的让晓勇改成post请求了. 不然我觉得凡是有点抓包能力的人抓到我们登录和注册这么涉及安全的东西居然用的是get请求, ...

  6. Robot Framework入门学习2 创建第一个测试用例

    本文章部分内容引自以下网址,感谢作者的辛苦分享 http://www.cnblogs.com/fnng/p/3871712.html http://blog.csdn.net/tulituqi/art ...

  7. EasyUI DataGrid getChecked/getSelections 获取不到数据

    今天使用getChecked获取选择的行,结果总是获取一行数据,于是换用getSelections,结果还是一样,想起之前做的项目,把idField换了下,之后getChecked/getSelect ...

  8. virtual 修饰符 C# .NET

    virtual 关键字用于修饰方法.属性.索引器或事件声明,并且允许在派生类中重写这些对象. 例如,此方法可被任何继承它的类重写. (C#参考) public virtual double Area( ...

  9. spring+struts2的jar

  10. (python)对象的引用

    对比下列两个例子: 例子1: a=10 b=a a=a+2 print "a=",a,"b=",b 结果:a= 12 b= 10 a+2后,b仍然是10 例子2 ...