\(\\\) \(Description\) \(T\) 组询问,每次给出一个 \(a\),求方程 \[ a-(a\oplus x)-x=0 \] 的方案数. \(T\le 10^3,a\le 2^{30}\) \(\\\) \(Solution\) 我菜又被巨佬 \(Diss\) 了...... 考场 \(NC\) 问了爷们半懂不懂的就过了...... 移项,得 \[ a=(a\oplus x)+x \] 然后注意到满足这个性质的 \(x\) ,在二进制表示下一定是 \(a\) 的子集. 因为…
Description Colossal! — exclaimed Hawk-nose. — A programmer! That's exactly what we are looking for. Arkadi and Boris Strugatsky. Monday starts on Saturday Reading the book "Equations of Mathematical Magic" Roman Oira-Oira and Cristobal Junta fo…
思路 打表找规律,发现结果是,2的(a二进制位为1总数)次方 代码 #include<bits/stdc++.h> using namespace std; #define ll long long int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll t,a; //freopen("in.txt","r",stdin); cin>>t; while(t--)…
题目要求解$a-(a\oplus x)-x=0$的解$x$的个数 移项得$a-x=a\oplus x$ $a$的二进制形式,应该是一个$01$串,异或的过程是不能影响到两个不同的位的,所以我们按位考虑 如果这一位是$0$,那么$x$的这一位也应为$0$,使得异或后答案不会更大 如果这一位是$1$,那么$x$的这一位可以为$0$或$1$,对应到减法中就是没减和减掉 所以答案就是$2^{count~~1~~in~~a}$ #include<iostream> #include<cstdio&…
https://blog.csdn.net/zfq17796515982/article/details/83051495 题意:解方程:a-(a^x)-x=0 给出a的值,要求计算解(非负)的个数 题解:需要^和 - 起到相同的效果. 1^1=0 1-1=0 1^0=1 1-0=1 0^0=0 0-0=0, 0^1=1 0-1=-1 a的二进制位上为1时,x的二进制位上为1或者0,异或和减的效果相同. a的二进制有几个1,就表示解的个数有2的几次方个 #include<bits/stdc++.…
A. Magic Spheres Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.codeforces.com/contest/606/problem/A Description Carl is a beginner magician. He has a blue, b violet and c orange magic spheres. In one move he can transform two spheres of the…
D. Magic Breeding link http://codeforces.com/contest/878/problem/D description Nikita and Sasha play a computer game where you have to breed some magical creatures. Initially, they have k creatures numbered from 1 to k. Creatures have n different cha…
D1. Magic Powder - 1 题目连接: http://www.codeforces.com/contest/670/problem/D1 Description This problem is given in two versions that differ only by constraints. If you can solve this problem in large constraints, then you can just write a single soluti…
D. Magic Numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Consider the decimal presentation of an integer. Let's call a number d-magic if digit d appears in decimal presentation of…
题目链接:http://codeforces.com/problemset/problem/495/B 题目意思:给出两个非负整数a,b,求出符合这个等式      的所有x,并输出 x 的数量,如果 x 有无限多个,那么输出 infinity. 想了半个多小时......有个地方想遗漏了. a mod x == b,等价于  a = k*x + b.设 mul = a - b,那么 k*x = mul,然后就不断枚举 mul 的因子,即 kx = mul.由于 mod 出来的结果为 b,那么…