设为首页 加入收藏

TOP

HDU 1412 {A} + {B}
2015-07-20 17:58:57 来源: 作者: 【 】 浏览:2
Tags:HDU 1412
Problem Description 给你两个集合,要求{A} + {B}.
注:同一个集合中不会有两个相同的元素.
Input 每组输入数据分为三行,第一行有两个数字n,m(0 Output 针对每组数据输出一行数据,表示合并后的集合,要求从小到大输出,每个元素之间有一个空格隔开.
Sample Input
1 2
1
2 3
1 2
1
1 2

Sample Output
1 2 3
1 2
看到大神用STL,写的如此犀利,忍不住来一发。。
#include
   
    
#include
    
      #include
     
       #include
      
        #include
       
         #include
        
          using namespace std; int main() { int n,m,x; list
         
          s1; list
          
           s2; while(cin>>n>>m) { for(int i=0;i
           
            >x; s1.push_back(x); } for(int i=0;i
            
             >x; s2.push_back(x); } s1.merge(s2); s1.sort(); s1.unique(); int cnt=0; while(!s1.empty()) { if(!cnt) cout<
             
              

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇HDU 1702 ACboy needs your help .. 下一篇跟着ZHONGHuan学习设计模式--工厂..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: