zoukankan      html  css  js  c++  java
  • nyoj 528 找球号(三)(哈希)

      点解:题目链接

    两种办法,1是使用容器set做

         2必须知道这个结论,  突然感觉数论很强大啊,,,,

     

    /*//set容器处理 出一次加进去,再出现删掉,这个最后留下的就是那个只出现基数次的
    #include <iostream>
    #include <set>
    
    using namespace std;
    int main()
    {
        set<int>s;
        int n;
        while(cin>>n)
        {
            int x;
            for(int i = 0; i < n; i++)
                {
                  cin>>x;
                  if(s.find(x) == s.end())
                        s.insert(x);
                    else
                    {
                        s.erase(x);
                    }
                }
            cout<<*s.begin()<<endl;
            s.clear();
        }
        return 0;
    }
    */
    
    //一个书数异或某些数的偶数次方,等于它本身
    #include <stdio.h>
    
    int main()
    {
        int n,x = 0,y;
        while(~scanf("%d",&n))
        {
            x = 0;
            while(n--){
            scanf("%d",&y);
            x = x ^ y;}
             printf("%d
    ",x);
        }
       return 0;
    }
    
  • 相关阅读:
    堆排序
    伽马分布
    隔壁-贪心
    对刚—约瑟夫环
    站军姿-两圆并集
    单纯的线性筛素数
    3兔子
    2.圆桌游戏
    1.花
    历史
  • 原文地址:https://www.cnblogs.com/yyroom/p/3272066.html
Copyright © 2011-2022 走看看