[ CodeForces 1064 B ] Equations of Mathematical Magic
\(\\\)
\(Description\)
\(T\) 组询问,每次给出一个 \(a\),求方程
\]
的方案数。
- \(T\le 10^3,a\le 2^{30}\)
 
\(\\\)
\(Solution\)
我菜又被巨佬 \(Diss\) 了......
考场 \(NC\) 问了爷们半懂不懂的就过了......
移项,得
\]
然后注意到满足这个性质的 \(x\) ,在二进制表示下一定是 \(a\) 的子集。
因为\(a\oplus x\)表示的是两者不交的部分的并集,再加上\(x\)表示的就是两个集合的并再加上 \(x\) 这一集合中 \(a\) 集合不包含的部分。
要是想要这个东西等于 \(a\) ,当且仅当 \(x\) 集合中不在 \(a\) 集合中的部分为空集。
然后就是统计 \(a\) 子集的个数。
显然一开始答案为 \(1\) ,遇到二进制位的一个 \(1\) 就答案个数就会翻倍。
\(\\\)
\(Code\)
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define R register
#define gc getchar
using namespace std;
typedef long long ll;
inline ll rd(){
  ll x=0; bool f=0; char c=gc();
  while(!isdigit(c)){if(c=='-')f=1;c=gc();}
  while(isdigit(c)){x=(x<<1)+(x<<3)+(c^48);c=gc();}
  return f?-x:x;
}
ll x,ans=1;
void work(){
    ans=1ll;
  x=rd();
  while(x){
    if((x&1ll)==1ll) ans<<=1;
    x>>=1;
  }
  printf("%I64d\n",ans);
}
int main(){
  ll t=rd();
  while(t--) work();
  return 0;
}
												
											[ CodeForces 1064 B ] Equations of Mathematical Magic的更多相关文章
- CF 1064B Equations of Mathematical Magic(思维规律)
		
Description Colossal! — exclaimed Hawk-nose. — A programmer! That's exactly what we are looking for. ...
 - B. Equations of Mathematical Magic
		
思路 打表找规律,发现结果是,2的(a二进制位为1总数)次方 代码 #include<bits/stdc++.h> using namespace std; #define ll long ...
 - CF1064B 【Equations of Mathematical Magic】
		
题目要求解$a-(a\oplus x)-x=0$的解$x$的个数 移项得$a-x=a\oplus x$ $a$的二进制形式,应该是一个$01$串,异或的过程是不能影响到两个不同的位的,所以我们按位考虑 ...
 - cf#516B. Equations of Mathematical Magic(二进制,位运算)
		
https://blog.csdn.net/zfq17796515982/article/details/83051495 题意:解方程:a-(a^x)-x=0 给出a的值,要求计算解(非负)的个数 ...
 - Codeforces Round #335 (Div. 2) A. Magic Spheres 水题
		
A. Magic Spheres Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.codeforces.com/contest/606/ ...
 - Codeforces Round #443 (Div. 1) D. Magic Breeding 位运算
		
D. Magic Breeding link http://codeforces.com/contest/878/problem/D description Nikita and Sasha play ...
 - Codeforces Round #350 (Div. 2) D1. Magic Powder - 1 二分
		
D1. Magic Powder - 1 题目连接: http://www.codeforces.com/contest/670/problem/D1 Description This problem ...
 - Codeforces CF#628 Education 8 D. Magic Numbers
		
D. Magic Numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...
 - codeforces   495B. Modular Equations   解题报告
		
题目链接:http://codeforces.com/problemset/problem/495/B 题目意思:给出两个非负整数a,b,求出符合这个等式 的所有x,并输出 x 的数量,如果 ...
 
随机推荐
- mysql转oracle注意事项
			
1.mysql中有自增长,oracle用新建sequence代替. 2.在实体类的id要指定相关的sequence @GeneratedValue(strategy=GenerationType.SE ...
 - neutron trouble shooting - ip can not ping
			
neutron创建了一个router后,显示列表如下: [root@controller01 keystone]# neutron router-port-list router +--------- ...
 - Open Flash Chart IO ERROR Loading test data Error #2032
			
http://blog.sina.com.cn/s/blog_6754464e0100qfvd.html Open Flash Chart 2 提示Open Flash Chart IO ERROR ...
 - Cocos2d-x 脚本语言Lua基本数据结构-表(table)
			
Cocos2d-x 脚本语言Lua基本数据结构-表(table) table是Lua中唯一的数据结构.其它语言所提供的数据结构,如:arrays.records.lists.queues.sets等. ...
 - 通讯编程入门--WEBSOCKET
			
C#通讯编程入门--WEBSOCKET WebSocket服务端 C#示例代码 using System; using System.Collections.Generic; using System ...
 - 内容原发网站seo不重视2个标签,导致seo效果不如转发网站
			
采集数据,挖掘观点,小心求证,得出结论 时间经过 今日凌晨,爬虫热点采集,其中第一财经是目标站之一,采集到了 http://www.yicai.com/news/5391233.html 谷歌去年悄然 ...
 - Bing必应地图中国API一显示地图  (转) 做人要厚道
			
Bing必应地图中国API一显示地图 2011-05-24 14:27:31| 分类: Bing&Google|字号 订阅 微软必应地图中国地图API发布已经有10天了,考虑到网上现 ...
 - Java 基础 —— enum
			
枚举的遍历: enum Suit { CLUB, DIAMOND, HEART, SPADE } Collection<Suit> suitTypes = Arrays.asList(Su ...
 - Ural 1517. Freedom of Choice 后缀数组
			
Ural1517 所谓后缀数组, 实际上准确的说,应该是排序后缀数组. 一个长度为N的字符串,显然有N个后缀,将他们放入一个数组中并按字典序排序就是后缀数组的任务. 这个数组有很好的性质,使得我们运行 ...
 - JsonFormat和DateTimeFormate格式化参数
			
JsonFormat :出参 DateTimeFormate : 入参 http://www.iteye.com/problems/53816 @DateTimeFormat(pattern = &q ...