#include <stdio.h>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <algorithm>
using namespace std;
const int MM=;
int num[MM];
int bit[];//记录下小的数的最高位的位置;
int b[];//记录当前数的二进制 顺序倒着
void change(int n)
{
int i=;
while(n)
{
b[i++]=n%;
n=n/;
}
}
int main()
{
int t,n,cnt;
cin>>t;
while(t--)
{
cin>>n;
memset(bit,,sizeof bit);
cnt=;
for(int i=;i<n;i++)
{
cin>>num[i];
}
sort(num,num+n);
int tmp=(int)log2(num[]);//最高位1的位置
bit[tmp]++;
for(int i=;i<n;i++)
{
int temp=(int)log2(num[i]);
memset(b,,sizeof b);
change(num[i]);//十进制转二进制
for(int j=;j<temp;j++)
{ if(b[j]==)
cnt+=bit[j];
}
bit[temp]++;//更新当前的bit
}
printf("%d\n",cnt);
}
return ;
}

Team Formation的更多相关文章

  1. 位运算 ZOJ 3870 Team Formation

    题目传送门 /* 题意:找出符合 A^B > max (A, B) 的组数: 位运算:异或的性质,1^1=0, 1^0=1, 0^1=1, 0^0=0:与的性质:1^1=1, 1^0=0, 0^ ...

  2. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Team Formation

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5494 The 12th Zhejiang Provincial ...

  3. 第十二届浙江省大学生程序设计大赛-Team Formation 分类: 比赛 2015-06-26 14:22 50人阅读 评论(0) 收藏

    Team Formation Time Limit: 3 Seconds Memory Limit: 131072 KB For an upcoming programming contest, Ed ...

  4. ZOJ3870 Team Formation

    /** Author: Oliver ProblemId: ZOJ3870 Team Formation */ /* 思路 1.异或运算,使用^会爆,想到二进制: 2.我们可以试着从前往后模拟一位一位 ...

  5. Team Formation(思维)

    Team Formation Time Limit: 3 Seconds      Memory Limit: 131072 KB For an upcoming programming contes ...

  6. 2015 浙江省赛B Team Formation (技巧,动归)

    Team Formation For an upcoming programming contest, Edward, the headmaster of Marjar University, is ...

  7. Zoj 3870——Team Formation——————【技巧,规律】

    Team Formation Time Limit: 3 Seconds      Memory Limit: 131072 KB For an upcoming programming contes ...

  8. ZOJ 3870 Team Formation 贪心二进制

                                                    B - Team Formation Description For an upcoming progr ...

  9. ZOJ 3870:Team Formation(位运算&思维)

    Team Formation Time Limit: 2 Seconds Memory Limit: 131072 KB For an upcoming programming contest, Ed ...

  10. 浙江省第十二届省赛 B - Team Formation

    Description For an upcoming programming contest, Edward, the headmaster of Marjar University, is for ...

随机推荐

  1. HDU 3853:LOOPS(概率DP)

    http://acm.split.hdu.edu.cn/showproblem.php?pid=3853 LOOPS Problem Description   Akemi Homura is a M ...

  2. 深入浅出Java垃圾回收机制

    JVM学习笔记 JVM内存管理和JVM垃圾回收 JVM内存组成结构 JVM内存结构由堆.栈.本地方法栈.方法区等部分组成,结构图如下所示: 1)堆 所有通过new创建的对象的内存都在堆中分配,其大小可 ...

  3. [充电]Code Review

    参考:http://blog.jobbole.com/83595/ http://www.kuqin.com/shuoit/20150319/345323.html 让 Code Review成为一种 ...

  4. 【转】卸载VMware时提示“The MSI failed”解决方案

    转载地址: http://www.2cto.com/os/201309/243843.html   安装精简版VM后再安装其他版本的VM,或者想升级安装更高的版本时,无法正常卸载(如提示The MSI ...

  5. java中MD5加密的小使用

    最近项目中需要用到md5加密,就自己在网上看了看. package com.wxgs.ch01; import java.security.MessageDigest; import java.sec ...

  6. PHP判断键值数组是否存在,使用empty或isset或array_key_exists

    <?php $a = array('a'=>1, 'b'=>0, 'c'=>NULL);   echo 'a test by empty: ' , empty($a['a']) ...

  7. poj1785 Binary Search Heap Construction

    此题可以先排序再用rmq递归解决. 当然可以用treap. http://poj.org/problem?id=1785 #include <cstdio> #include <cs ...

  8. define与typedef 区别

    1)     #define是预处理指令,在编译预处理时进行简单的替换,不作正确性检查,不关含义是否正确照样带入,只有在编译已被展开的源程序时才会发现可能的错误并报错.例如:#define PI 3. ...

  9. 用python requests库写一个人人网相册爬虫

    担心人人网会黄掉,写个爬虫,把我的相册照片都下载下来.代码如下: # -*- coding: utf-8 -*- import requests import json import os def m ...

  10. centos6.5用户添加到sudoers中

    一.将用户添加到sudoers su vi /etc/sudoers :x! success 二.解释 su 目的是使用最高root权限去进行修改操作 vi /etc/sudoers 使用vi编辑器打 ...