当前位置: 首页 > news >正文

wordpress商品分销西安整站优化

wordpress商品分销,西安整站优化,住房和城乡建设主管部门网站,用jsp做电影网站的界面位运算#蓝桥杯 文章目录 位运算#蓝桥杯1、小蓝学位运算2、异或森林3、位移4、笨笨的机器人5、博弈论 1、小蓝学位运算 #include<bits/stdc.h> using namespace std; using LL long long; const LL N 1e97; template<int kcz> struct ModInt { #define T (*this)…

位运算#蓝桥杯

文章目录

  • 位运算#蓝桥杯
    • 1、小蓝学位运算
    • 2、异或森林
    • 3、位移
    • 4、笨笨的机器人
    • 5、博弈论

1、小蓝学位运算

在这里插入图片描述

#include<bits/stdc++.h>
using namespace std;
using LL = long long;
const LL N = 1e9+7; 
template<int kcz>
struct ModInt {
#define T (*this)int x;ModInt() : x(0) {}ModInt(int y) : x(y >= 0 ? y : y + kcz) {}ModInt(LL y) : x(y >= 0 ? y % kcz : (kcz - (-y) % kcz) % kcz) {}inline int inc(const int &v) {return v >= kcz ? v - kcz : v;}inline int dec(const int &v) {return v < 0 ? v + kcz : v;}inline ModInt &operator+=(const ModInt &p) {x = inc(x + p.x);return T;}inline ModInt &operator-=(const ModInt &p) {x = dec(x - p.x);return T;}inline ModInt &operator*=(const ModInt &p) {x = (int) ((LL) x * p.x % kcz);return T;}inline ModInt inverse() const {int a = x, b = kcz, u = 1, v = 0, t;while (b > 0)t = a / b, std::swap(a -= t * b, b), std::swap(u -= t * v, v);return u;}inline ModInt &operator/=(const ModInt &p) {T *= p.inverse();return T;}inline ModInt operator-() const {return -x;}inline friend ModInt operator+(const ModInt &lhs, const ModInt &rhs) {return ModInt(lhs) += rhs;}inline friend ModInt operator-(const ModInt &lhs, const ModInt &rhs) {return ModInt(lhs) -= rhs;}inline friend ModInt operator*(const ModInt &lhs, const ModInt &rhs) {return ModInt(lhs) *= rhs;}inline friend ModInt operator/(const ModInt &lhs, const ModInt &rhs) {return ModInt(lhs) /= rhs;}inline bool operator==(const ModInt &p) const {return x == p.x;}inline bool operator!=(const ModInt &p) const {return x != p.x;}inline ModInt qpow(LL n) const {ModInt ret(1), mul(x);while (n > 0) {if (n & 1)ret *= mul;mul *= mul, n >>= 1;}return ret;}inline friend std::ostream &operator<<(std::ostream &os, const ModInt &p) {return os << p.x;}inline friend std::istream &operator>>(std::istream &is, ModInt &a) {LL t;is >> t, a = ModInt<kcz>(t);return is;}static int get_mod() {return kcz;}inline bool operator<(const ModInt &A) const {return x > A.x;}inline bool operator>(const ModInt &A) const {return x < A.x;}
#undef T
};
using Z=ModInt<N>;
int main(){ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);int n;cin>>n;if(n>8192){cout<<"0\n";return 0;}vector<int> a(n),sum_xor(n+1,0);for(auto &x:a)cin>>x;/*为什么使用前缀异或和? 快速计算任意区间的异或结果有了前缀异或和,如果要计算区间 [l, r] 的异或结果只需要通过 sum_xor[r+1] ^ sum_xor[l] 即可得到结果因为在l之前的数据包都是一样的,异或结果都是0 */Z ans = 1;for(int i=1;i<=n;i++)sum_xor[i]=sum_xor[i-1]^a[i-1];for(int i=1;i<=n;i++){for(int j=i;j<=n;j++){ans*=sum_xor[i-1]^sum_xor[j];}} cout<<ans;return 0;
}

2、异或森林

在这里插入图片描述

#include<bits/stdc++.h>
using namespace std;
int main(){ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);int n;cin>>n;vector<int> a(n),sum_xor(n+1,0);for(auto &x:a)cin>>x;for(int i=1;i<=n;i++)sum_xor[i]=sum_xor[i-1]^a[i-1];/*是需要咱们找到连续子数组的数量n * (n + 1) / 2 表示长度为1的子数组有 n 个长度为2的子数组有 n-1 个,以此类推最终得到总共 n * (n + 1) / 2 个子数组所以,n(n+1)/2 = 连续子数组个数 */int ans = n * (n + 1) / 2;// 记录每个前缀异或和的次数 vector<int> cnt(4 * n + 1);cnt[0] = 1;/*n  x|n  n/x|n if x=n/x,那么说明这个n的因数就是奇数个了,因为这两个数一样所以·判断条件就是 x^2=n因为 奇数 个好判断,所以我们列举出来所有可能的数量就是ans让 ans 减去奇数个的就行了 */ for (int r = 1; r <= n; r++) {for (int i = 0; i * i <= 2 * n; i++) {ans -= cnt[sum_xor[r] ^ (i * i)];}cnt[sum_xor[r]]++;}cout << ans << '\n';return 0;
}

3、位移

在这里插入图片描述

#include<bits/stdc++.h>
using namespace std;
int main(){ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);int n;cin>>n;while(n--){unsigned int a,b;cin>>a>>b;while(!(a&1))a>>1;while(!(b&1))b>>1;if(a<b){cout<<"No\n";return 0;} // 因为输入的是10进制,所以我们要转化这两个数的二进制状态vector<int> A,B;while(a>0){A.push_back(a&1);a=>>1;}while(b>0){B.push_back(b&1);b=>>1;}  //判断 b 是否在 a 里面int n = (int) A.size(), m = (int) B.size();// 字符串匹配 for (int i = 0; i + m - 1 < n; i++) {int fl = 0;for (int j = 0; j < m; j++) {// 对于 A 来讲 肯定是 每次移动,B 从头开始的 if (A[i + j] != B[j]) {fl = 1;break;}}}if (!fl) {cout << "Yes\n";return 0;}cout << "No\n";} return 0;
}

4、笨笨的机器人

在这里插入图片描述

#include<bits/stdc++.h>
using namespace std;
int main(){ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);int n;cin>>n;vector<int> a(n);for(auto &x:a)cin>>x; int cnt = 0;// 枚举集合,此时 S 的每一位表示第 i 个数是加还是减// 为了生成长度为 n 的二进制数的所有可能情况// 通过这种方法来穷举所有的子集合for (int S = 0; S < 1 << n; S++) {int p = 0;// 求第 i 位是加还是减for (int i = 0; i < n; i++) {// S >> i & 1 的意思是先做 S >> i,再 & 1,含义是 S 的第 i 位是不是 1// S >> i 等价于 S / 2 ^ i 下取整,意味着去除了最后的 i 位,此时个位数 (二进制) 是原数第 i 位// x & 1 等价于与 1 取 and,也就是只有 x 的个位与 1 做了 and,即 x 的个位数是不是 1if (S >> i & 1)p += a[i];else p -= a[i];}if (p % 7 == 0)cnt++;}double ans = (double)cnt/(1<<n);ans = round(ans * 1e4) / 1e4;cout<<fixed<<setprecision(4)<<ans;return 0;
}

在这里插入图片描述

5、博弈论

在这里插入图片描述

http://www.hkea.cn/news/526354/

相关文章:

  • 高端大气的网站制作南宁百度seo软件
  • 沙井营销型网站建设成人培训机构
  • 网站没有被百度收录搜索引擎排名优化公司
  • 手机网站转换小程序晋江怎么交换友情链接
  • 专业做网站的公司疫情放开最新消息今天
  • 不用写代码做网站软件长沙优化网站
  • o2o商城网站建设方案广告策划案优秀案例
  • 日照做网站的那家做的好百度网页链接
  • 建设云个人证件查询系统上海seo培训
  • 网站流量提供商杭州seo排名
  • 做装饰工程的在什么网站投标自建站
  • 地球人--一家只做信誉的网站帮忙推广的平台
  • 网站建设外包协议天津网站排名提升
  • 邯郸教育行业网站建设百度推广代理商查询
  • 政府网站有哪些网站seo最新优化方法
  • 做广告牌子seo外链工具
  • 微信页面设计网站兰州网络推广技术
  • 上门做网站搜狗站长工具
  • wordpress用户邮箱验证码百度seo搜索引擎优化培训
  • 360极速怎么屏蔽网站新闻热点大事件
  • 购物app开发价格表站长工具seo排名
  • 微餐饮网站建设营销型网站建设方案
  • 高端网站建设公司好不好2020国内搜索引擎排行榜
  • 网站建设服务公司选哪家比较好?苏州优化收费
  • 中国建设银行河南省分行网站推广信息哪个平台好
  • 网站建设官网免费模板杭州seo优化
  • 绍兴网站建设谷歌搜索引擎在线
  • 网站的会员认证怎么做黑龙江新闻头条最新消息
  • 做网站如何分工百度推广登录平台客服
  • 网站建设如何提案万网域名注册信息查询