& -- 位运算之一,有0则0

原题链接  Problem - 1514B - Codeforces

题目

Example
input
2
2 2
100000 20
output
4
226732710

题意

t个测试样例,在每个样例中

数组有n个数,数字范围[ 0, 2- 1]

使得数组每个数&后,结果=0,并且这n个数的和要尽量大

输出有多少个这样的数组

解析

数组每个数&后,结果=0  -->每一位至少一个0

数要尽量大  -->只要这一位可以 != 0, 就为 1

先假设每个数都为2k - 1, (每个数的每一位都=1),

对于每一位有且仅有一个数=0,有n种选法.

代码

#include <iostream>

using namespace std;

typedef long long ll;

const int mod = 1e9+7;

int main()
{
int t; cin >> t;
while(t --)
{
int n, k;
ll res = 1;
cin >> n >> k;
while(k--)
res = res*n%mod;
cout << res << endl;
}
return 0;
}

补充

---- 一个难一点的&运算 Divide by Zero 2021 and Codeforces Round #714 (Div. 2) B. AND Sequences思维,位运算 难度1400 - la-la-wanf - 博客园 (cnblogs.com)

Codeforces Round #716 (Div. 2), problem: (B) AND 0, Sum Big位运算思维的更多相关文章

  1. Codeforces Round #721 (Div. 2)A. And Then There Were K(位运算,二进制) B1. Palindrome Game (easy version)(博弈论)

    半个月没看cf 手生了很多(手动大哭) Problem - A - Codeforces 题意 给定数字n, 求出最大数字k, 使得  n & (n−1) & (n−2) & ...

  2. Codeforces Round #590 (Div. 3) D. Distinct Characters Queries(线段树, 位运算)

    链接: https://codeforces.com/contest/1234/problem/D 题意: You are given a string s consisting of lowerca ...

  3. Codeforces Round #320 (Div. 2) [Bayan Thanks-Round] A. Raising Bacteria【位运算/二进制拆分/细胞繁殖,每天倍增】

    A. Raising Bacteria time limit per test 1 second memory limit per test 256 megabytes input standard ...

  4. Codeforces Round #267 (Div. 2) B. Fedor and New Game【位运算/给你m+1个数让你判断所给数的二进制形式与第m+1个数不相同的位数是不是小于等于k,是的话就累计起来】

    After you had helped George and Alex to move in the dorm, they went to help their friend Fedor play ...

  5. Codeforces Round #539 (Div. 2) - C. Sasha and a Bit of Relax(思维题)

    Problem   Codeforces Round #539 (Div. 2) - C. Sasha and a Bit of Relax Time Limit: 2000 mSec Problem ...

  6. Codeforces Round #306 (Div. 2), problem: (B) Preparing Olympiad【dfs或01枚举】

    题意: 给出n个数字,要求在这n个数中选出至少两个数字,使得它们的和在l,r之间,并且最大的与最小的差值要不小于x.n<=15 Problem - 550B - Codeforces 二进制 利 ...

  7. Codeforces Round #753 (Div. 3), problem: (D) Blue-Red Permutation

    还是看大佬的题解吧 CFRound#753(Div.3)A-E(后面的今天明天之内补) - 知乎 (zhihu.com) 传送门  Problem - D - Codeforces 题意 n个数字,n ...

  8. Codeforces Round #243 (Div. 2) Problem B - Sereja and Mirroring 解读

    http://codeforces.com/contest/426/problem/B 对称标题的意思大概是.应当指出的,当线数为奇数时,答案是线路本身的数 #include<iostream& ...

  9. Codeforces Round #439 (Div. 2) Problem E (Codeforces 869E) - 暴力 - 随机化 - 二维树状数组 - 差分

    Adieu l'ami. Koyomi is helping Oshino, an acquaintance of his, to take care of an open space around ...

随机推荐

  1. Spring MVC 实验2-Bean的几种装配方式及基本用法

    实验二:Bean的几种装配方式及基本用法  实验目的: (1)掌握2种基于XML的装配方式:设值注入(Setter Injection)和构造注入(Constructor Injection) . ( ...

  2. Arcgis Server发布的带有透明度的地图服务,调用时不显示透明度问题

    问题: 在发布道路地图时候设置地图透明度为50% 使用arcgis API for js 中 ArcGISDynamicMapServiceLayer 调用该地图时,发现透明效果不实现 如下图: 解决 ...

  3. 使用tc配置后端设备,来限制虚拟机网卡带宽

    如果通过tc来限制虚拟机网卡接收方向带宽呢,实际上使用tc对接收方向限制的不够好,使用tc ingress可以限制接收,但是功能不够多,而且会形成丢包问题.一般是采用将流量重定向到一个虚拟设备ifb上 ...

  4. 【论文阅读】CVPR2022: Learning from all vehicles

    Column: March 23, 2022 1:08 PM Last edited time: March 23, 2022 11:13 PM Sensor/组织: 现leaderboard第一名, ...

  5. Linux下mysql的彻底卸载

    1.查看mysql的安装情况 rpm -qa | grep -i mysql 2.删除上图安装的软件 rpm -ev mysql-community-libs-5.7.27-1.el6.x86_64 ...

  6. css--BFC是什么,有什么用,怎么用?

    前言 作为前端开发人员或者学生,你一定知道BFC这个关键词,但是你是否具体了解过什么是BFC?BFC有什么用?BFC怎么用些问题呢?本文就来总结一下相关的知识点,希望对阅读到的小伙伴在面试.学习.开发 ...

  7. Linux磁盘分区管理-LVM回顾

    LVM(逻辑分区管理)的几个概念:PV(物理卷),VG(卷组),LV(逻辑卷),PE(物理区域),LE(逻辑区域),其中PV, VG, LV 三者之间的关系如下图 : 物理存储介质:这里指系统的存储设 ...

  8. 安卓开发学习-app结构学习

    开发软件:Android Studio 全局分析 gradle与idea是AS自动生成的文件 buid是编译时生成的文件 gradle里面包含gradle wrapper配置文件 gitignore是 ...

  9. 半吊子菜鸟学Web开发 -- PHP学习 4 --异常

    PHP异常处理 1 抛出一个异常 与Python的try except类似,PHP用try catch来捕获异常 基本语法 try{ //可能出现错误或异常的代码 //catch表示捕获,Except ...

  10. Elman network with additional notes

    // Author: John McCullock // Date: 10-15-05 // Description: Elman Network Example 1. //http://www.mn ...