Codeforces 164 E Compatible Numbers】的更多相关文章

主题链接~~> 做题情绪:好题,做拉的比赛的时候想了非常久,想到枚举变幻某一位的 0 为 1 .可是每一个数都这样枚举岂不超时的节奏,当时没想到事实上从大到小枚举一次就 ok 了. 解题思路: 本题要求两个数  a & b = 0 , 假设 a  =  10010 , b 至少(指在 a 中的为 1 的位必须为 0 )是 01101 ,还能够是 00101 ,00001 .00000.就相当于你去买东西一样,先提出你的要求(必须满足).至于其它方面都无所谓. 这样我们能够枚举 b 中的 1…
LINK 题目大意 给你一个数组,问你数组中的每个数是否可以在数组里面找到一个数和他and起来是0,如果可以就输出这个数,否则就输出-1 思路 首先很显然的是可以考虑找到每个数每一位都取反的数的子集 如果子集中存在一个数就满足,否则就不满足 然后就做一个子集前缀和 for (int i = 0; i < n; i++) { for (int s = 0; s <= up; s++) { if ((s >> i) & 1) dp[s] trans from dp[s ^ (1…
E. Compatible Numbers time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Two integers x and y are compatible, if the result of their bitwise "AND" equals zero, that is, a & b = 0. Fo…
[codeforces 55]D. Beautiful numbers 试题描述 Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer number is beautiful if and only if it is divisible by each of its nonzero digits. We will not argue with this and…
wo integers x and y are compatible, if the result of their bitwise "AND" equals zero, that is, a&b = 0. For example, numbers90(10110102) and 36(1001002) are compatible, as 10110102&1001002 = 02, and numbers 3(112) and 6(1102) are not com…
题目 传送门:QWQ 分析 很难想到方向,但有方向了就很easy了. 我们如何减少不必要的计算? 如果我们知道了$ 100111 $的相容的数,$ 100101 $的相容数和他是完全一样的. 我们就靠着这个思想写一下就行了. 注意位运算优先级. 代码 #include <bits/stdc++.h> using namespace std; <<, INF=(<<)-; int dp[maxn], a[maxn]; int main(){ int n; scanf(&q…
B. Ancient Berland Hieroglyphs 题目连接: http://codeforces.com/problemset/problem/164/B Descriptionww.co Polycarpus enjoys studying Berland hieroglyphs. Once Polycarp got hold of two ancient Berland pictures, on each of which was drawn a circle of hierog…
http://codeforces.com/contest/934 A. A Compatible Pair   time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Nian is a monster which lives deep in the oceans. Once a year, it shows up on the la…
Codeforces Round #597 (Div. 2 Consider the set of all nonnegative integers: 0,1,2,-. Given two integers a and b (1≤a,b≤104). We paint all the numbers in increasing number first we paint 0, then we paint 1, then 2 and so on. Each number is painted whi…
Alyona and Numbers 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/A Description After finishing eating her bun, Alyona came up with two integers n and m. She decided to write down two columns of integers - the first column containing inte…