Team Formation
#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的更多相关文章
- 位运算 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^ ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Team Formation
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5494 The 12th Zhejiang Provincial ...
- 第十二届浙江省大学生程序设计大赛-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 ...
- ZOJ3870 Team Formation
/** Author: Oliver ProblemId: ZOJ3870 Team Formation */ /* 思路 1.异或运算,使用^会爆,想到二进制: 2.我们可以试着从前往后模拟一位一位 ...
- Team Formation(思维)
Team Formation Time Limit: 3 Seconds Memory Limit: 131072 KB For an upcoming programming contes ...
- 2015 浙江省赛B Team Formation (技巧,动归)
Team Formation For an upcoming programming contest, Edward, the headmaster of Marjar University, is ...
- Zoj 3870——Team Formation——————【技巧,规律】
Team Formation Time Limit: 3 Seconds Memory Limit: 131072 KB For an upcoming programming contes ...
- ZOJ 3870 Team Formation 贪心二进制
B - Team Formation Description For an upcoming progr ...
- ZOJ 3870:Team Formation(位运算&思维)
Team Formation Time Limit: 2 Seconds Memory Limit: 131072 KB For an upcoming programming contest, Ed ...
- 浙江省第十二届省赛 B - Team Formation
Description For an upcoming programming contest, Edward, the headmaster of Marjar University, is for ...
随机推荐
- .Net额外小工具
http://blog.csdn.net/zhumi/article/details/49076 用于编写单元测试的 NUnit用于创建代码文档资料的 NDoc用于生成解决方案的 NAnt用于生成代码 ...
- 加载 pcntl 多进程
加载 pcntl 有两种方式 一种重新编译安装,在编译时加 --enable-pcntl ./configure --prefix=/usr/local/php --with-mysql=/usr/l ...
- Java异常捕获之try-catch-finally-return的执行顺序-转载
情况1:try块中没有抛出异常try和finally块中都有return语句 public static int NoException(){ int i=10; try{ System.out.pr ...
- [ios][swift]Swift类型之间转换
http://www.ruanman.net/swift/learn/4741.html
- [团队项目]后续安排 Github
6.后续安排 第16周 周二晚7点之前将本代码上传到GITHUB. 周三上课时运行你们的系统给我观赏一下. 根据博客,运行演示,github代码情况评定第二个冲刺的分数. 至此,软件工程学期平时分截止 ...
- css3 动画 执行一次
function testAnim(x) { $('#animationSandbox').removeClass().addClass(x + ' animated').one('webkitA ...
- js笔记---封装自己的Ajax方法
//地址 成功方法 失败方法function Ajax(url, funsucc, funfial) { var oAjax = null; if (window.XMLHttpRequest) { ...
- javascript学习(三) 内置对象
一:事件(Event)对象 在触发dom事件的时候都会产生一个event对象 type 获取事件类型 target 获取事件目标 stopPropagation() 阻止事件冒泡 preven ...
- Android中@id与@+id区别
Android中的组件需要用一个int类型的值来表示,这个值也就是组件标签中的id属性值. id属性只能接受资源类型的值,也就是必须以@开头的值,例如,@id/abc.@+id/xyz等. 如果在@后 ...
- 自定义ViewPager控制是否滑动
package com.lvshandian.menshen.view;/** * Created by zhang on 2016/11/8. * 创建自定义滑动,禁止滑动的ViewPager */ ...