Description For an upcoming programming contest, Edward, the headmaster of Marjar University, is forming a two-man team from N students of his university. Edward knows the skill level of each student. He has found that if two students with skill leve…
时间限制:10000ms 单点时限:1000ms 内存限制:256MB   描述 Rowdark是一个邪恶的魔法师.在他阅读大巫术师Lich的传记时,他发现一类黑魔法来召唤远古生物,鱼丸. 魔法n能召唤类型i鱼丸当且仅当i能够被表示为x xor n*x对于某个正整数x和固定的n. Rowdark想知道类型为[L,R]之间的鱼丸有多少种能被魔法n召唤. 输入 输入第一行包含个整数n(1 ≤ n ≤ 107). 第二行包含两个整数,L, R(0 ≤ L ≤ R ≤ 107). 输出 一行一个整数表示…
Description   Team Queue   Team Queue  Queues and Priority Queues are data structures which are known to most computer scientists. The Team Queue, however, is not so well known, though it occurs often in everyday life. At lunch time the queue in fron…
Description Edward has an array A with N integers. He defines the beauty of an array as the summation of all distinct integers in the array. Now Edward wants to know the summation of the beauty of all contiguous subarray of the array A. Input There a…
For an upcoming programming contest, Edward, the headmaster of Marjar University, is forming a two-man team from N students of his university. Edward knows the skill level of each student. He has found that if two students with skill level A and B fo…
/** Author: Oliver ProblemId: ZOJ3870 Team Formation */ /* 思路 1.异或运算,使用^会爆,想到二进制: 2.我们可以试着从前往后模拟一位一位的^那么只要当前位结果变大便是: 3.一般我们如何利用二进制呢?既然要爆那我们就存1的位置: 4.问题是怎么存,如何用? 5.我之前想的是每个数的每位1都存,但是那样造成的重复计算还没想出怎么避免.看了一下别人的博客,再尝试把每位数的最高位1存起来. 6.想想为什么是存最高位呢: 7.那好,现在是不…
题目链接:http://acm.sgu.ru/problem.php?contest=0&problem=275 这是一道xor高斯消元. 题目大意是给了n个数,然后任取几个数,让他们xor和最大. 首先根据题目意思可以列出下列方程组: //a11x1+a21x2……=d[1] //a12x1+a22x2……=d[2] //... (每个数二进制按列来写,xi为0或1,表示取或不取这个数.) 结果的二进制即为d数组. 由于需要结果最大,而结果最多是d全为1,那么就假设所有d均为1,然后进行高斯消…
Description Friend number are defined recursively as follows. (1) numbers 1 and 2 are friend number; (2) if a and b are friend numbers, so is ab+a+b; (3) only the numbers defined in (1) and (2) are friend number. Now your task is to judge whether an…
进制 二进制   0 1组成,封2进1 八进制 0-7组成,封8进1 十进制 0-9组成,封10进1 十六进制 0-15组成,封16进1 printf以不同进制形式进行输出 变量的内存地址形式 变量在内存中是从高地址到低地址依次保存的,并且只保存二进制 查看内存地址的两种方式:%x和%p 各个类型变量的取值范围 类型修饰符 在64bit编译器环境下, int占用4个字节(32bit),取值范围是-231~231-1: short占用2个字节(16bit),取值范围是-215~215-1: lon…
http://nanti.jisuanke.com/t/15 题目要求是求出只出现一次的数字,其余数字均出现三次. 之前有过一个题是其余数字出现两次,那么就是全部亦或起来就得到答案. 这题有些不太一样. 显然,最裸的做法就是cnt[i]表示i出现的次数.然后求出cnt[i]为1的那一个. 然后可能会考虑到,对于这些数字的二进制位来看,某一位二进制位出现3的倍数次的话,那么只出现一次的数字这一位一定是0.如果出现3的倍数加1次,那么自然,只出现一次的数字这一位一定是1. 然后就考虑用cnt[i]表…