#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. destoon短信接口修改方法

    destoon是很优秀的B2B行业站程序.程序模块化开发契合度很高,二次开发起来也很顺畅.数据缓存,权限分配,SEO功能方面都不错. 但是在使用这套程序的时候,常常要用到发送短信的功能,而destoo ...

  2. 关于android中Bundle的使用

      1.Android using Bundle for sharing variables 注:android中使用Bundle来共享变量,下例中Activity1和Activity2通过bundl ...

  3. vc6

    适合win7使用的: http://pan.baidu.com/s/1nt7SG57

  4. JAVA基础知识之JVM-——反射和泛型

    泛型和Class类 在反射中使用泛型Class<T>可以避免强制类型转换,下面是一个简单例子,如果不使用泛型的话,需要显示转换, package aop; import java.util ...

  5. Spring 中的页面重定向

    在写 java 程序设计实践作业的时候遇到了重定向页面的需求,因为还没学到 java web 开发,所以自己就在网上搜了一下相关的代码,总结出了一些小小的经验,希望在下学期学 java web 的时候 ...

  6. HDU 4920 Matrix multiplication 矩阵相乘。稀疏矩阵

    Matrix multiplication Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/ ...

  7. zoj Treasure Hunt IV

    Treasure Hunt IV Time Limit: 2 Seconds      Memory Limit: 65536 KB Alice is exploring the wonderland ...

  8. mysql获取当前时间,及其相关操作

    获取UNIX时间戳 : UNIX_TIMESTAMP(NOW()) 1.1 获得当前日期+时间(date + time)函数:now() 除了 now() 函数能获得当前的日期时间外,MySQL 中还 ...

  9. Codeoforces 558 B. Duff in Love

    //   B. Duff in Love time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  10. CocoaPods的安装[转载]

    [转载] 原地址http://www.tuicool.com/articles/7VvuAr3 觉得很好,很有用 iOS 最新版 CocoaPods 的安装流程 1.移除现有Ruby默认源 $gem ...