SP5973 SELTEAM - Selecting Teams

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll read()
{
ll s=; bool f=; char ch=' ';
while(!isdigit(ch)) {f|=(ch=='-'); ch=getchar();}
while(isdigit(ch)) {s=(s<<)+(s<<)+(ch^); ch=getchar();}
return (f)?(-s):(s);
}
#define R(x) x=read()
inline void write(ll x)
{
if(x<) {putchar('-'); x=-x;}
if(x<) {putchar(x+''); return;}
write(x/); putchar((x%)+'');
}
#define W(x) write(x),putchar(' ')
#define Wl(x) write(x),putchar('\n')
const int N=;
const ll Mod=;
ll T,n,k;
ll C[N][];
inline void Ad(ll &x,ll y)
{
x+=y; x-=(x>=Mod)?Mod:;
}
int main()
{
ll i,j,ans;
R(T);
C[][]=;
for(i=;i<=;i++)
{
C[i][]=; for(j=;j<=min(23ll,i);j++) C[i][j]=(C[i-][j]+C[i-][j-])%Mod;
}
while(T--)
{
R(n); R(k); ans=;
for(i=;i<=min(k,23ll);i++) Ad(ans,C[n][i]*i%Mod*(1ll<<(i-))%Mod);
Wl(ans);
}
return ;
}
/*
input
3
2 2
7 1
5 3
output
6
7
165
*/

spoj5973的更多相关文章

随机推荐

  1. kubernetes 水平伸缩及yaml格式编写

    Replication Controller:用来部署.升级PodReplica Set:下一代的Replication ControllerDeployment:可以更加方便的管理Pod和Repli ...

  2. String的equals和hashCode方法

    对于判断对象是否相等,肯定需要重写它的equals和hashCode方法.不然使用默认的方法只会比较地址,因此会出现错误. 以String类为例,且看它的equals方法 public boolean ...

  3. 怎样获取当前文档所有的元素节点(即html标签节点)

    方法1. 使用 document.getElementsByTagName("*"); 方法2. 使用document.querySelectorAll("*" ...

  4. .js文件中文乱码解决办法

    描述:.js文件里的中文内容在网页中显示乱码 解决办法:把JS文件的编码改为utf-8 VS2013解决步骤:文件——高级保存选项——Unicode (UTF-8带签名)  代码页 65001

  5. # 使用scatter()绘制散点图

    使用scatter()绘制散点图 之前写过一篇,使用magic function快速绘图的教程了:https://www.cnblogs.com/jiading/p/11750001.html.但这种 ...

  6. 【C++】如何提高Cache的命中率,示例

    参考链接     https://stackoverflow.com/questions/16699247/what-is-a-cache-friendly-code 只是堆积:缓存不友好与缓存友好代 ...

  7. 7.移动端自动化测试-小知识 try...except...finally语句

    异常Error 我们在写代码的时候,经常会遇见程序抛出Error无法执行的情况 一般情况下,在Python无法正常处理程序时就会发生一个异常.异常是Python对象,表示一个错误.当Python脚本发 ...

  8. WPF实战案例-在线程内同步集合数据到UI线程

    有这样一个场景,在vm中,我们为了ui的体验,会异步访问后端接口,获取数据集合,如果这个集合绑定到界面,并且在线程内,怎么处理? 有人讲:this.Dispatcher.Invoke,如果在vm内呢? ...

  9. Linux环境下交叉编译器安装及运行

    描述: 由于 使用第三方编译器是提示No such file or directory 原因:编译器为32位版本,而系统是64位的 解决方法:安装32位版本编译支持库 sudo apt-get ins ...

  10. VTORRAAYY ws+tls+nginx config

    # nginx conf partal location /haha { proxy_redirect off; # the prot should same with config v2*** pr ...