zoukankan      html  css  js  c++  java
  • CF1299A Anu Has a Function

    首先 (f(x,y)=x) (or) (y-y=x) (and) (y),那么我们只需要枚举每一位,看是否有且仅有一个数的第 (i) 位为 (1),如果有,则将它放在第一个。

    #include <bits/stdc++.h>
    #define reg register
    #define ll long long
    #define ull unsigned long long
    #define db double
    #define pi pair<int, int>
    #define pl pair<ll, ll>
    #define vi vector<int>
    #define vl vector<ll>
    #define vpi vector<pi>
    #define vpl vector<pl>
    #define pb push_back
    #define er erase
    #define SZ(x) (int) x.size()
    #define lb lower_bound
    #define ub upper_bound
    #define all(x) x.begin(), x.end()
    #define rall(x) x.rbegin(), x.rend()
    #define mkp make_pair
    #define dmin(x, y) ((x) < (y) ? (x) : (y))
    #define dmax(x, y) ((x) > (y) ? (x) : (y))
    #define checkmax(x, y) ((x) < (y) ? ((x) = (y)) : (x))
    #define checkmin(x, y) ((x) > (y) ? ((x) = (y)) : (x))
    #define ms(data_name) memset(data_name, 0, sizeof(data_name))
    #define msn(data_name, num) memset(data_name, num, sizeof(data_name))
    #define For(i, j) for(reg int (i) = 1; (i) <= (j); ++(i))
    #define For0(i, j) for(reg int (i) = 0; (i) < (j); ++(i))
    #define Forx(i, j, k) for(reg int (i) = (j); (i) <= (k); ++(i))
    #define Forstep(i , j, k, st) for(reg int (i) = (j); (i) <= (k); (i) += (st))
    #define fOR(i, j) for(reg int (i) = (j); (i) >= 1; (i)--)
    #define fOR0(i, j) for(reg int (i) = (j) - 1; (i) >= 0; (i)--)
    #define fORx(i, j, k) for(reg int (i) = (k); (i) >= (j); (i)--)
    #define tour(i, u) for(reg int (i) = head[(u)]; (i) != -1; (i) = nxt[(i)])
    using namespace std;
    char ch, B[1 << 20], *S = B, *T = B;
    #define getc() (S == T && (T = (S = B) + fread(B, 1, 1 << 20, stdin), S == T) ? 0 : *S++)
    #define isd(c) (c >= '0' && c <= '9')
    int rdint() {
      int aa, bb;
      while(ch = getc(), !isd(ch) && ch != '-');
      ch == '-' ? aa = bb = 0 : (aa = ch - '0', bb = 1);
      while(ch = getc(), isd(ch))
        aa = aa * 10 + ch - '0';
      return bb ? aa : -aa;
    }
    ll rdll() {
      ll aa, bb;
      while(ch = getc(), !isd(ch) && ch != '-');
      ch == '-' ? aa = bb = 0 : (aa = ch - '0', bb = 1);
      while(ch = getc(), isd(ch))
        aa = aa * 10 + ch - '0';
      return bb ? aa : -aa;
    }
    const int MAXN = 1e5 + 10;
    int n, a[MAXN];
    inline void work() {
      n = rdint();
      For(i, n) {
        a[i] = rdint();
      }
      fOR0(i, 32) {
        int cnt = 0, pos = 0;
        For(j, n) {
          if(a[j] & (1 << i)) {
            ++cnt;
            pos = j;
          }
        }
        if(cnt == 1) {
          swap(a[1], a[pos]);
          break;
        }
      }
      For(i, n) {
        printf("%d ", a[i]);
      }
      printf("
    ");
    }
    int main() {
      // freopen("input.txt", "r", stdin);
      work();
      return 0;
    }
    
  • 相关阅读:
    一阶倒立摆分析
    用Matlab进行部分分式展开
    2013/07/11 中科院软件所就业讲座总结
    解决vs2010“创建或打开C++浏览数据库文件 发生错误”的问题 Microsoft SQL Server Compact 3.5
    centos安装
    Mongodb——GridFS
    MongoDB—— 写操作 Core MongoDB Operations (CRUD)
    MongoDB—— 读操作 Core MongoDB Operations (CRUD)
    数据库
    影像数据库调研
  • 原文地址:https://www.cnblogs.com/Lonely-233/p/13659161.html
Copyright © 2011-2022 走看看