SP5973 SELTEAM - Selecting Teams

【题目描述】

他已经有 n 个心仪的妹子了,但随着时间的流逝,只有 m(1<=m<=k)个直伴随在他的身边,而小小迪发现他只爱上了这其中的 l(1<=l<=m)个妹子从这 l 个中选出一个妹子作为他的真爱,向她告白。但小小迪并不知道未来会发生什么,他可以得知的只有 n 和 k。你作为小小迪的专属膜法师,决定帮助他算出未来会有多少种不同的爱情故指 m 个妹子不同或 l 个妹子不同或真爱不同,m,l 见上文)小小迪会历经 T 世情劫,所以你要帮他算 T 次。答案对 8388608取模。(2^23)【输入格式】第一行一个数 T。接下来 T 行每行两个数表示 n 和 k。

【输出格式】

输出 T 行 每行一个整数表示答案。

【样例输入 1】

3

2 2

7 1

5 3

【样例输出 1】

6

7

165

【数据包规模】

对于 40%的数据 1<=k<=n,T<=200;

对于另 20%的数据 T=1;

对于 100%的数据 1<=T<=10000,1<=k<=n<=10000

sol:如果看完题毫无思路是正确的,在你没有发现Mod=8388608=223前这就是到不可做题。

因为是223,容易知道(XJB乱猜)m只要枚举到23就可以了(我怕溢出枚举到25),事实证明果然是这样(对拍拍上了)

Ps:代码真的很短,但是仍然非常丑丑丑丑丑

#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%)+'');
return;
}
#define W(x) write(x),putchar(' ')
#define Wl(x) write(x),putchar('\n')
const ll Mod=;
int T,n,Up;
ll C[][];
int main()
{
int i,j;
C[][]=;
for(i=;i<=;i++)
{
C[i][]=;
for(j=;j<=;j++)
{
C[i][j]=(C[i-][j-]+C[i-][j])%Mod;
}
}
R(T);
while(T--)
{
ll ans=;
R(n); R(Up);
for(i=;i<=min(,Up);i++)
{
for(j=;j<=i;j++)
{
ans+=C[n][i]*C[i][j]%Mod*j%Mod;
ans-=(ans>=Mod)?Mod:;
}
}
Wl(ans);
}
return ;
}
/*
input
3
2 2
7 1
5 3
output
6
7
165
*/

SP5973 SELTEAM - Selecting Teams的更多相关文章

  1. spoj5973

    SP5973 SELTEAM - Selecting Teams #include <bits/stdc++.h> using namespace std; typedef long lo ...

  2. End up with More Teams UVA - 11088

    End up with More Teams Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu ...

  3. Rnadom Teams

    Rnadom  Teams 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.actioncid=88890#problem/B 题目: Descript ...

  4. poj 2239 Selecting Courses (二分匹配)

    Selecting Courses Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8316   Accepted: 3687 ...

  5. Study on Algorithm of Selecting Safe Landing Area on Ground During Asteroid Soft Landing (EEIC2013 +161)

    OUATTARA Sie, RUAN Xiaogang, Yan yan Institute of Artificial Intelligence and Robots, School of Elec ...

  6. URAL 1208 Legendary Teams Contest(DFS)

    Legendary Teams Contest Time limit: 1.0 secondMemory limit: 64 MB Nothing makes as old as years. A l ...

  7. timus 1106 Two Teams(二部图)

    Two Teams Time limit: 1.0 secondMemory limit: 64 MB The group of people consists of N members. Every ...

  8. CF478 B. Random Teams 组合数学 简单题

    n participants of the competition were split into m teams in some manner so that each team has at le ...

  9. Jmeter-Maven-Plugin高级应用:Selecting Tests To Run

    地址:https://github.com/jmeter-maven-plugin/jmeter-maven-plugin/wiki/Advanced-Configuration Selecting ...

随机推荐

  1. NodeJS之path模块

    NodeJS之path模块 常用的主要有如下工具函数: 1. path.basename(path[, ext]) 2. path.extname(path) 3. path.dirname(path ...

  2. PAT A1021 Deepest Root (25 分)——图的BFS,DFS

    A graph which is connected and acyclic can be considered a tree. The hight of the tree depends on th ...

  3. kubernete 数据库 etcd

    etcdctl --cert-file /etc/ssl/etcd/ssl/member-pserver78.pem --key-file /etc/ssl/etcd/ssl/member-pserv ...

  4. SkylineDemoForWeb JavaScript二次开发示例代码

    SkylineDemoForWeb JavaScript二次开发示例代码 http://files.cnblogs.com/files/yitianhe/SkylineDemoForWeb.zip

  5. 关于TerraBuilder的扩展开发

    熟悉Skyline的朋友,可能会发现,在最新的6.6的产品体系中,TerraBuilder中用于生成三维地形场景的模块,改成了TerrainBuilder. 通常情况下,这款软件模块,我们主要用它来进 ...

  6. LOJ #559. 「LibreOJ Round #9」ZQC 的迷宫

    一道ZZ结论题,主要是来写一写交互题的. 我们要先知道一句话: 扶着墙是肯定可以走出简单迷宫的. 然后我们冷静分析问题.若这个迷宫是\(n\times m\)的,那么最多有\(2mn+n+m\)个墙壁 ...

  7. 12.4 开课三个月(phpcms安装)

    cms的样式有很多种,我们学习的是phpcms,这些cms都是大同小异,学会了一种就可以使用其它的cms. PHPCMS是一款网站管理软件.该软件采用模块化开发,支持多种分类方式,使用它可方便实现个性 ...

  8. [HNOI2018]游戏[拓扑排序]

    题意 题目链接 分析 先将没有锁的房间缩点,首先有一个 \(O(n^2)\) 的想法:从每个点出发,每次检查能否向两边扩张. 容易发现门和门之间如果有锁,必然只有一方能够开锁(只有一把钥匙),并且能够 ...

  9. mysql操作命令梳理(4)-grant授权和revoke回收权限

    在mysql维护工作中,做好权限管理是一个很重要的环节.下面对mysql权限操作进行梳理: mysql的权限命令是grant,权限撤销的命令时revoke:grant授权格式:grant 权限列表 o ...

  10. UserControl 的一个值得注意的问题 [属性" * "的代码生成失败.错误是:"程序集"*.Version=1.0.0.0,Culture=neutral,..........无标记为序列化"

    开发时在做UserControl,需要注意的List<>集合问题~~~! 其他类型的集合可能也存在这样的问题,但是我没去测试,在写集合的时候一般List<>用的多点,所以经常碰 ...