Codeforces Round #716 (Div. 2), problem: (B) AND 0, Sum Big位运算思维
& -- 位运算之一,有0则0
原题链接 Problem - 1514B - Codeforces
题目

2
2 2
100000 20
4
226732710

题意
t个测试样例,在每个样例中
数组有n个数,数字范围[ 0, 2k - 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位运算思维的更多相关文章
- 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) & ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- Codeforces Round #306 (Div. 2), problem: (B) Preparing Olympiad【dfs或01枚举】
题意: 给出n个数字,要求在这n个数中选出至少两个数字,使得它们的和在l,r之间,并且最大的与最小的差值要不小于x.n<=15 Problem - 550B - Codeforces 二进制 利 ...
- Codeforces Round #753 (Div. 3), problem: (D) Blue-Red Permutation
还是看大佬的题解吧 CFRound#753(Div.3)A-E(后面的今天明天之内补) - 知乎 (zhihu.com) 传送门 Problem - D - Codeforces 题意 n个数字,n ...
- Codeforces Round #243 (Div. 2) Problem B - Sereja and Mirroring 解读
http://codeforces.com/contest/426/problem/B 对称标题的意思大概是.应当指出的,当线数为奇数时,答案是线路本身的数 #include<iostream& ...
- 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 ...
随机推荐
- 记录VMware安装VMware Tools过程及遇到的一些问题
镜像下载.域名解析.时间同步请点击 阿里云开源镜像站 本文以CentOS安装为例 为什么要安装VMware Tools ? 便于在Windows 下更好管理虚拟机 便于设置Windows和CentOS ...
- 7月2日 Django 生成验证码、
html页面里 {# 验证码 #} <div class="form-group " id="v-code-wrapper"> <label ...
- Cobalt Strike之LINK木马
在同一目录下 新建一个exp.ps1 一个test.txt exp.ps1代码 $file = Get-Content "test.txt" $WshShell = New-Obj ...
- hutool包里的ObjectUtil.isNull和ObjectUtil.isEmpty的区别
大家都用过hutool包把,包路径为:cn.hutool.core.util,最近再使用的过程中一直没高明白ObjectUtil.isEmpty和ObjectUtil.isNull两者到底有那些区别, ...
- 【Vulnhub练习】Acid
靶机信息 下载链接 https://download.vulnhub.com/acid/Acid.rar 靶机说明 Welcome to the world of Acid. Fairy tails ...
- 论文翻译:2021_论文翻译:2018_F-T-LSTM based Complex Network for Joint Acoustic Echo Cancellation and Speech Enhancement
论文地址:https://arxiv.53yu.com/abs/2106.07577 基于 F-T-LSTM 复杂网络的联合声学回声消除和语音增强 摘要 随着对音频通信和在线会议的需求日益增加,在包括 ...
- mock axios vue的数据传递关系
最近有一个项目要快速出一个前端demo,选择了vue-element框架(虽然其实很想用react,但是为了求快) 本人的基础只有初级的html/css/js知识,和python后端的一些简单工作,和 ...
- Golang 包了解以及程序的执行
Golang 包了解以及程序的执行 引言 Go 语言是使用包来组织源代码的,包(package)是多个 Go 源码的集合,是一种高级的代码复用方案.Go 语言中为我们提供了很多内置包,如 fmt.o ...
- Hadoop全分布式
1.安装jdk Linux下安装jdk-7u67-linux-x64.rpm 2.免密登录 ssl免密登录(centos6) 3.同步时间:date -s "2020-04-0 ...
- 什么是 Spring 的 MVC 框架?
Spring 配备构建 Web 应用的全功能 MVC 框架.Spring 可以很便捷地和其他 MVC 框架集成,如 Struts,Spring 的 MVC 框架用控制反转把业务对象和控制逻 辑清晰地隔 ...