HDU 5058 So easy (set容器大法好)

题目链接:HDU 5058
So easy

题意:给出两个序列,问这个两个序列构成的集合是否相同、

set大法好!

AC代码:

#include<stdio.h>
#include<set>
#include<map>
using namespace std;
#define ll __int64
set<ll> ss1,ss2;
set<ll>::iterator it;
int main()
{
    ll n,i;
    while(scanf("%I64d",&n)!=EOF)
    {
        ll num;
        ss1.clear();
        ss2.clear();
        for(i=0;i<n;i++)
        {
            scanf("%I64d",&num);
            ss1.insert(num);
        }
        bool flag=true;
        for(i=0;i<n;i++)
        {
            scanf("%I64d",&num);
            ss2.insert(num);
        }
        if(ss2.size()!=ss1.size())
            printf("NO\n");
        else
        {
            int temp=ss1.size();
            for(it=ss2.begin();it!=ss2.end();it++)
                ss1.insert(*it);
            if(temp==ss1.size())
                printf("YES\n");
            else
                printf("NO\n");
        }

    }
return 0;
}
时间: 2024-10-07 00:51:44

HDU 5058 So easy (set容器大法好)的相关文章

HDU 5058 So easy(STL set运用)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5058 Problem Description Small W gets two files. There are n integers in each file. Small W wants to know whether these two files are same. So he invites you to write a program to check whether these two

HDU 5058 So easy

http://acm.hdu.edu.cn/showproblem.php?pid=5058 题目大意: 给定两个集合,两个集合的元素都为n,求两个集合是否相等. 例如:A集合={5,3,7,7},B集合={7,5,3,3},则A集合等于B集合, 因为他们都有{3,5,7}.C集合={2,5,2,5},D集合={2,5,2,3},C集合和B集合是不等的. 因为C={2,5},D={2,3,5} 解题思路: 对A集合和B集合排序,然后去掉重复的元素,再比较. AC代码: 1 #include<io

杭电OJ(HDU)-ACMSteps-Chapter Two-《An Easy Task》《Buildings》《decimal system》《Vowel Counting》

http://acm.hdu.edu.cn/game/entry/problem/list.php?chapterid=1§ionid=2 1.2.5 #include<stdio.h> /* 题意:找闰年. if((i%4==0 && i%100!=0) || i%400==0)count++; 3 2005 25 1855 12 2004 10000 2108 1904 43236 */ int main() { int t,y,n; int i,count=0; whil

HDU 4565 So Easy!

线性推,矩阵乘法+快速幂求通项. 传送门:点击打开链接 #include <cstdio> #include <cstring> #include <cmath> #include <iostream> using namespace std; #define LL long long struct Mat{ LL f[2][2]; }; LL MOD; Mat mul(Mat a,Mat b) { LL i,j,k; Mat c; memset(c.f,0

BestCoder12 1001.So easy(hdu 5058) 解题报告

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5058 (格式有点问题,为了方便阅读---整个复制下来吧) 题目意思:给出两个长度都为 n 的集合你,问这两个集合是否相等. 其实思路非常容易想到,就是去重后判断嘛---我用到了set 来做.不过有个小细节!!! 1 #include <iostream> 2 #include <cstdio> 3 #include <cstdlib> 4 #include <cstr

HDU 4565 So Easy! 矩阵快速幂 + 共轭数

题意:中文题 So Easy 解题思路: 这题应该是 HDU 2256的原题 , 根据类似的结论可以推出 中间矩阵 ta  1 tb ta 原矩阵 1 1 解题代码: 1 // File Name: temp.cpp 2 // Author: darkdream 3 // Created Time: 2014年09月17日 星期三 11时35分45秒 4 5 #include<vector> 6 #include<list> 7 #include<map> 8 #inc

数据结构(主席树):HDU 4729 An Easy Problem for Elfness

An Easy Problem for Elfness Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 1148    Accepted Submission(s): 234 Problem Description Pfctgeorge is totally a tall rich and handsome guy. He plans t

hdu 1040 As Easy As A+B

As Easy As A+B Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 53368    Accepted Submission(s): 22939 Problem Description These days, I am thinking about a question, how can I get a problem as

HDU 5650 so easy

so easy Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 617    Accepted Submission(s): 413 Problem Description Given an array with n integers, assume f(S) as the result of executing xor operati