当前位置:网站首页>B. AND 0, Sum Big-Codeforces Round #716 (Div. 2)
B. AND 0, Sum Big-Codeforces Round #716 (Div. 2)
2022-06-23 17:21:00 【Qin Sanma】
B. AND 0, Sum Big
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Baby Badawy's first words were "AND 0 SUM BIG", so he decided to solve the following problem. Given two integers nn and kk, count the number of arrays of length nn such that:
- all its elements are integers between 00 and 2k−12k−1 (inclusive);
- the bitwise AND of all its elements is 00;
- the sum of its elements is as large as possible.
Since the answer can be very large, print its remainder when divided by 109+7109+7.
Input
The first line contains an integer tt (1≤t≤101≤t≤10) — the number of test cases you need to solve.
Each test case consists of a line containing two integers nn and kk (1≤n≤1051≤n≤105, 1≤k≤201≤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+7109+7.
Example
input
Copy
2 2 2 100000 20
output
Copy
4 226732710
Note
In the first example, the 44 arrays are:
- [3,0][3,0],
- [0,3][0,3],
- [1,2][1,2],
- [2,1][2,1].
==================================================================================================================================================
& The operation requires that only one of them be 0 The result must be 0, And if we want to maximize the results , The best way is, of course n individual 2^k-1, But this and the operation are not 0,. We can get n-1 All numbers 2^k-1, There's one left 0, That is to say k All places are 0 The situation of . But this k A place is 0 The case is randomly assigned to n A number does not affect the size of the answer , So the answer is n^k, It can be solved quickly
# include<iostream>
# define mod 1000000007
using namespace std;
typedef long long int ll;
ll quickpow(ll base, ll pow)
{
ll ans=1;
while(pow)
{
if(pow&1)
ans=ans*base%mod;
pow>>=1;
base=base*base%mod;
}
return ans;
}
int main ()
{
int t;
cin>>t;
while(t--)
{
ll n,k;
cin>>n>>k;
cout<<quickpow(n,k)<<endl;
}
return 0;
}
边栏推荐
- 查数据库中每张表的大小
- JMeter stress testing tutorial
- Why do we say that the data service API is the standard configuration of the data midrange?
- 三分钟学会如何找回mysql密码
- 接口的所有权之争
- How important is 5g dual card dual access?
- ABAP essays - program optimization notes
- 官方零基础入门 Jetpack Compose 的中文课程来啦
- Importance of ERP management system
- 如何选择示波器?这10点一定要考虑!
猜你喜欢

QT布局管理器【QVBoxLayout,QHBoxLayout,QGridLayout】

Here comes the official zero foundation introduction jetpack compose Chinese course!

JS common error reporting and exception capture
![[go]沙盒环境下调用支付宝扫码支付](/img/d4/c6d72a697bc08f69f11121a15109b3.png)
[go]沙盒环境下调用支付宝扫码支付

公司招了个五年经验的测试员,见识到了真正的测试天花板

亚朵更新招股书:继续推进纳斯达克上市,已提前“套现”2060万元

How to use SQL window functions

ASEMI超快恢复二极管ES1J参数,ES1J封装,ES1J规格

What does the timestamp 90K mean?

《MPLS和VP体系结构》
随机推荐
What is an abstract class? How to define abstract classes?
ASEMI肖特基二极管和超快恢复二极管在开关电源中的对比
时间戳90K是什么意思?
如何选择示波器?这10点一定要考虑!
走好数据中台最后一公里,为什么说数据服务 API 是数据中台的标配?
ABAP随笔-程序优化笔记
相机电源受干扰案例分析,严重影响画质
R language uses colorblinr package to simulate color blind vision, and uses edit to visualize the image of ggplot2_ The colors function is used to edit and convert color blindness into visual results
[qsetting and.Ini configuration files] and [create resources.qrc] in QT
右腿驱动电路原理?心电采集必备,有仿真文件!
Rongyun: let the bank go to the "cloud" easily
C#与数据库连接
The R language uses the RMSE function of the yardstick package to evaluate the performance of the regression model, the RMSE of the regression model on each fold of each cross validation (or resamplin
Freemark uses FTL files to generate word
Troubleshooting of datanode entering stale status
Opengauss database source code analysis series articles -- detailed explanation of dense equivalent query technology (Part 1)
I successfully joined the company with 27K ByteDance. This interview notes on software testing has benefited me for life
R language ggplot2 visualizes horizontal boxplot with coord_flip, and adds jittered data points to display the distribution
手机开户股票开户需要多久?在线开户安全么?
混沌工程在云原生中间件稳定性治理中的实践分享