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 ...
随机推荐
- Linux下C语言复制文件
从usr/bin/info复制到myinfo.c #include<unistd.h> #include<fcntl.h> #include<sys/types.h> ...
- JavaWeb 08_JSP+Dao+Bean+Servlet 实现登录注册(连接数据库,验证码登录,两周内免登陆等功能)
一.数据库db_01 表usert 字段username,password 二. 目录 三. 配置信息 四. 代码 index.jsp <script type="text/j ...
- 钓鱼+DNS欺骗学习笔记
钓鱼+DNS欺骗学习笔记 0x00 写在前面 原文链接: http://www.cnblogs.com/hkleak/p/5186523.html 感谢大佬无私教学 0x01 步骤如下 第一步:布置钓 ...
- 盘点几种DIY加密狗的制作方法,适用于穿越机模拟器
前言 前几天笔者的加密狗在使用中突然坏掉了,现象是插电脑不识别,LED灯不亮. 网上很多模友也反映了同样的问题: http://bbs.5imx.com/forum.php?mod=viewthrea ...
- 集成SpringCloudBus,但没有总线通知更改
配置服务端别忘了添加以下2个依赖 implementation("org.springframework.cloud:spring-cloud-config-server")imp ...
- 关于kafka客户端版本与服务端版本不一致导致的一次坑
上周开发了一个功能,需要使用kafka接上游数据并入库,本地开发时,自己安装了一个kafka服务,开发测试时使用本地的kafka服务给主题发消息,然后在自己本地的代码中进行调试.使用的kafka版本如 ...
- Auth0案例学习(SpringMVC形式)
官方SpringMVC示例Github:https://github.com/auth0-samples/auth0-spring-mvc-sample/tree/master/01-Login Ma ...
- springboot-数据库访问之jpa
什么是springDate? springData的作用: 整体简化的架构: JPA :Java Persistence API 如果没有springData 我们需要去学每一种对应的jpa实现, 有 ...
- Altium Designer 原理图的绘制前导
元件库.封装库设计 部分元器件厂商或者经销商不提供元件库和封装库,只给了元器件尺寸图,所以需要自行设计元件库文件或是封装库文件 元件库设计: 新建 .SchLib 文件:File -> N ...
- A小程序与B小程序相互跳转的一点记录
要点速览: A小程序和B小程序关联同一个公众号 B程序的用户授权 A小程序和B小程序的用户关联 诸葛 io 统计用户访问信息 需求:微信放开小程序互跳的 API 后,一些导流和拉新等活动可以在新的小程 ...