Codeforces Round #716 (Div. 2), B. AND 0, Sum Big, 快速幂结论题
problem
B. AND 0, Sum Big
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
Baby Badawy’s first words were “AND 0 SUM BIG”, so he decided to solve the following problem. Given two integers n and k, count the number of arrays of length n such that:
all its elements are integers between 0 and 2k−1 (inclusive);
the bitwise AND of all its elements is 0;
the sum of its elements is as large as possible.
Since the answer can be very large, print its remainder when divided by 109+7.
Input
The first line contains an integer t (1≤t≤10) — the number of test cases you need to solve.
Each test case consists of a line containing two integers n and k (1≤n≤105, 1≤k≤20).
Output
For each test case, print the number of arrays satisfying the conditions. Since the answer can be very large, print its remainder when divided by 109+7.
Example
inputCopy
2
2 2
100000 20
outputCopy
4
226732710
Note
In the first example, the 4 arrays are:
[3,0],
[0,3],
[1,2],
[2,1].
B. AND 0,总和
每次测试的时限2秒
每个测试的内存限制256 MB
输入标准输入
输出标准输出
Baby Badawy的第一个单词是“ AND 0 SUM BIG”,因此他决定解决以下问题。给定两个整数n和k,计算长度为n的数组的数量,使得:
它的所有元素都是0到2k-1(含)之间的整数;
其所有元素的按位与为0;
其元素的总和应尽可能大。
由于答案可能非常大,因此请打印除以109 + 7所得的余数。
输入
第一行包含一个整数t(1≤t≤10)-您需要解决的测试用例数。
每个测试用例由包含两个整数n和k(1≤n≤105,1≤k≤20)的一行组成。
输出
对于每个测试用例,打印满足条件的数组数。由于答案可能非常大,因此请打印除以109 + 7所得的余数。
例子
inputCopy
2
2 2
100000 20
outputCopy
4
226732710
笔记
在第一个示例中,这四个数组是:
[3,0],
[0,3],
[1,2],
[2,1]。
solution
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 1e5+10;
const int mod = 1e9+7;LL mpow(LL a, LL x) {if(x==0)return 1;LL t = mpow(a, x>>1);if(x%2==0)return t*t%mod;return t*t%mod*a%mod;
}int main(){ios::sync_with_stdio(false);//init();int T; cin>>T;while(T--){int n, k; cin>>n>>k;cout<<mpow(n,k)<<"\n";}return 0;
}
Codeforces Round #716 (Div. 2), B. AND 0, Sum Big, 快速幂结论题相关推荐
- Codeforces Round #716 (Div. 2) D. Cut and Stick 主席树 + 思维
传送门 文章目录 题意: 思路: 题意: 给你个长为nnn的数组aaa,定义好的区间为这个区间中每个数出现的次数≤⌈n2⌉\le \left \lceil \frac{n}{2} \right \rc ...
- Codeforces Round #716 (Div. 2) D(随机算法)
Codeforces Round #716 (Div. 2) D 题意:区间查询,问区间最少能分成几部分使得最多的数不超过总数的一半 向上取整. 思路:找到区间的总数s,如果不超过一半的话就是一部分. ...
- Codeforces Round #716 (Div. 2)
Codeforces Round #716 (Div. 2) CodeForces 1514 题号 题目 知识点 难度 A Perfectly Imperfect Array B AND 0, Sum ...
- Codeforces Round #636 (Div. 3) D.Constant Palindrome Sum
Codeforces Round #636 (Div. 3) D.Constant Palindrome Sum 题目链接 You are given an array a consisting of ...
- Codeforces Round #636 (Div. 3) D. Constant Palindrome Sum 思维 + 差分
传送门 文章目录 题意: 思路: 题意: 思路: 首先有一个显然的性质就是每组操作最多不会超过两次. 很容易想到一个很暴力的思路,就是枚举x∈[1,2∗k]x \in [1,2*k]x∈[1,2∗k] ...
- Codeforces Round #716 (Div. 2) (位运算AND)
B. AND 0, Sum Big time limit per test2 seconds memory limit per test256 megabytes inputstandard inpu ...
- Codeforces Round #716 Div.2 部分题解
这场难度比之前几场友好了许多. A. Perfectly Imperfect Array 题意: 给出一个数组aaa,判断其是否存在一个子序列bbb使得bbb中的元素乘积不是平方数.若是,输出YES, ...
- Codeforces Round #716 (Div. 2)ABCDE题解
目录 A.Perfectly Imperfect Array B.AND 0, Sum Big C.Product 1 Modulo N D.Cut and Stick 莫队 随机化算法(官方 线段树 ...
- Codeforces Round 775(Div.2) Problem C Weird Sum(匿名函数的使用)
原题链接 C++ Lambda函数(匿名函数)的使用方法 首先了解一下 C++ 匿名函数的基本使用方法 基本语法 //[捕获列表](参数列表)->返回类型{函数体} auto f = []( ...
最新文章
- 6001.Cacti监控华为S8512核心交换机多块板卡的CPU和内存
- Material Master
- 网络基础——知识生活化会变得如此简单
- VS中怎样打开MSDN帮助文档
- javascript 中文与Unicode相互转化
- ddr4服务器内存频率_镁光出样DDR5内存;紫光发布P5160系列SSD!
- Java开发人员必须看到的13个Decks保持更新
- Android中的数据库
- 【剑指offer】面试题22:链表中倒数第k个节点(Java)
- 主键、聚集索引、非聚集索引区别
- 华为确定2019年目标:超三星成全球最大智能手机供应商
- ssms安装_SQLServer 2019下载及安装教程
- HDU.1006 Tick and Tick
- 各种好用的开源库。快点进来,包你喜欢~^_^
- reset.css(样式重置)
- 数据结构上机实验解题报告
- AMADA阿玛达触摸屏维修折弯机主机维修
- 哈夫曼树的构造和哈夫曼编码实现详细讲解(含例题详细讲解)
- 学习笔记(2):程序员的数学:微积分-常用导数(二):最常用到的技巧
- DC-DC隔离电源模块与非隔离电源模块有什么区别?