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…
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++.…
思路 打表找规律,发现结果是,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&…
\(\\\) \(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\) 的子集. 因为…
UVa10025 ? 1 ? 2 ? ... ? n = k problem The problem Given the following formula, one can set operators '+' or '-' instead of each '?', in order to obtain a given k? 1 ? 2 ? ... ? n = k For example: to obtain k = 12 , the expression to be used will be:…
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/contest/374/problem/A 题意:求到达边界的最小步数.. 刚开始以为是 bfs,不过数据10^6太大了,肯定不是... 一个思维题,要注意超边界... #include <iostream> #include <cstring> #include <algorithm> using namespace std; <<); int n,m,x,y,a,b; int ok(int x1,int…
Description: 遇到了ogo可以变成***如果ogo后面有go统统忽略,输出结果 Solution: 哎如果我一开始对题意的解读如上的话,就不会被整的那么麻烦了 Code: #include <iostream> #include <cstdio> #include <cstring> using namespace std; const int maxn = 150; /***找到一个题目的规律,做题的方法是多么的重要!!***/ /***以后没有好的方法,…
E. Vasya and Magic Matrix http://codeforces.com/contest/1042/problem/E 题意: 一个n*m的矩阵,每个位置有一个元素,给定一个起点,每次随机往一个小于这个点位置走,走过去的值为欧几里得距离的平方,求期望的值. 分析: 逆推期望. 将所有值取出,按元素大小排序,然后最小的就是0,往所有大于它的转移即可,复杂度n^2,见下方考试代码. 考虑每个点,从所有小于它的元素转移.排序后,维护前缀和,可以做到O(1)转移. $f[i] =…