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. 高显卡安装 低版本的ubuntu系统导致hdmi线不能用

  2. JS-详解算数运算符"+"

    二元加法运算符“+”可以对两个数字做加法,也可以做字符串连接操作: 当两个操作数都是数字或都是字符串的时候,计算结果是显而易见的.然而对于其他情况来说,则要进行一些必要的类型转换,并且运算符的行为依赖 ...

  3. WPF 滚动文字控件MarqueeControl

    原文:WPF 滚动文字控件MarqueeControl WPF使用的滚动文字控件,支持上下左右滚动方式,支持设置滚动速度 XAML部分: <UserControl x:Class="U ...

  4. HDU3062&&HDU1814

    Preface 两道2-SAT模板题. HDU3062 看题目就一眼2-SAT.一对夫妻看成一个变量,之间的矛盾可以看成限制. 考虑不同席的限制,相当于选了\(i\)就不选\(j\),即必选\(j'\ ...

  5. Luogu P4016 负载平衡问题

    传说中的网络流24题之一,我刷的第二题菜. 据说这种东西做完了就可以有质的飞越?不过看着这些Luogu评级就有点蒙蔽. 首先我们看一下题目发现这不是均分纸牌的加强板吗,但是那个环的操作极大地限制了我的 ...

  6. 【强化学习】python 实现 q-learning 例五(GUI)

    本文作者:hhh5460 本文地址:https://www.cnblogs.com/hhh5460/p/10143579.html 感谢pengdali,本文的 class Maze 参考了他的博客, ...

  7. aurora 64B/66B ip核设置与例程代码详解

    见网页https://blog.csdn.net/u014586651/article/details/84349328 https://blog.csdn.net/u012135070/articl ...

  8. 2016年总结 - Java程序员

    一 . 技术积累 (1)代码规范 1.1.1.通常的模块分布:一般如果你要实现一个web应用,你从后台将数据展示到前端页面,在一个比较大的公司,你少不了跟其他项目有交集(你调用他的接口,他依赖你的接口 ...

  9. C# 8中的Async Streams

    关键要点 异步编程技术提供了一种提高程序响应能力的方法. Async/Await模式在C# 5中首次亮相,但只能返回单个标量值. C# 8添加了异步流(Async Streams),允许异步方法返回多 ...

  10. C#_XML与Object转换

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.X ...