zoukankan      html  css  js  c++  java
  • [MtOI2019]永夜的报应

    [MtOI2019]永夜的报应

    这个题猛地一看其实是感觉非常难的.
    但是,冷静分析一下,你会发现:
    因为(x : xor : y le x + y),所以说一个子序列一个子序列地异或和加起来肯定大于等于所有数字的异或和.
    于是得到答案是所有数字的异或和.愉快 (AC.)
    当然,卡卡常是为了(rank)高一点,毕竟(IOI)赛制.

    #include <algorithm>
    #include <iostream>
    #include <cstdlib>
    #include <cstring>
    #include <cstdio>
    #include <string>
    #include <vector>
    #include <queue>
    #include <cmath>
    #include <map>
    #define MEM(x,y) memset ( x , y , sizeof ( x ) )
    #define rep(i,a,b) for (int i = a ; i <= b ; ++ i)
    #define per(i,a,b) for (int i = a ; i >= b ; -- i)
    #define pii pair < int , int >
    #define X first
    #define Y second
    #define rint read<int>
    
    using std::pair ;
    using std::max ;
    using std::min ;
    using std::priority_queue ;
    using std::vector ;
    
    namespace fastIO {
        #define BUF_SIZE 100000
        bool IOerror = 0;
        inline char nc() {
            static char buf[BUF_SIZE], *p1 = buf + BUF_SIZE, *pend = buf + BUF_SIZE;
            if(p1 == pend) {
                p1 = buf;
                pend = buf + fread(buf, 1, BUF_SIZE, stdin);
                if(pend == p1) {
                    IOerror = 1;
                    return -1;
                }
            }
            return *p1++;
        }
        inline bool blank(char ch) {
            return ch == ' ' || ch == '
    ' || ch == '
    ' || ch == '	';
        }
        inline void read(int &x) {
            char ch;
            while(blank(ch = nc()));
            if(IOerror) return;
            for(x = ch - '0'; (ch = nc()) >= '0' && ch <= '9'; x = x * 10 + ch - '0');
        }
        #undef BUF_SIZE
    };
    
    using namespace fastIO;
    
    template < class T >
        inline void write (T x) {
            if ( x < 0 ) putchar('-') , x = - x ;
            if ( x > 9 ) write ( x / 10 ) ;
            putchar ( x % 10 + '0' ) ;
        }
    
    const int N = 1e6 + 100 ;
    
    int n , v[N] , ans ;
    
    int main() {
        read ( n ) ;
        rep ( i , 1 , n ) read ( v[i] ) , ans ^= v[i] ;
        write ( ans ) ;
        system ("pause") ; return 0 ;
    }
    
    May you return with a young heart after years of fighting.
  • 相关阅读:
    利用Python编写简单的Web静态服务器(TCP协议)
    UDP-TCP介绍与区别
    Linux基本知识-命令
    Python中多线程与join()的应用
    Python实例---对一组含有四则运算,括号,空格的字符串进行计算
    分组查询注意事项
    oracle分页查询
    springMVC文件上传配置
    ssm网站页面乱码问题解决
    redis-server.exe闪退
  • 原文地址:https://www.cnblogs.com/Equinox-Flower/p/11405150.html
Copyright © 2011-2022 走看看