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. PAT A1099 Build A Binary Search Tree (30 分)——二叉搜索树,中序遍历,层序遍历

    A Binary Search Tree (BST) is recursively defined as a binary tree which has the following propertie ...

  2. 【Codeforces 467D】Fedor and Essay

    Codeforces 467 D 题意:给\(m​\)个单词,以及\(n​\)个置换关系,问将\(m​\)个单词替换多次后其中所含的最少的\(R​\)的数量以及满足这个数量的最短总长度 思路:首先将置 ...

  3. 3.0+百度地图在地图初始化的时候就弹框展示一个信息框,而不是用户点击poi时才弹出

    有些时候我们会有这样的业务:当用户根据地址跳转到地图后,希望能够立即弹框展示该poi的地址信息. 实现方法: 百度地图3.0+的类BaiduMap中提供了一个方法showInfoWindow(Info ...

  4. rook 入门理解

    参考:https://my.oschina.net/u/2306127/blog/1830356?from=timeline 1.Rook通过一个操作器(operator)完成后续操作,只需要定义需要 ...

  5. Java多线程编程模式实战指南一:Active Object模式(上)

    Active Object模式简介 Active Object模式是一种异步编程模式.它通过对方法的调用与方法的执行进行解耦来提高并发性.若以任务的概念来说,Active Object模式的核心则是它 ...

  6. CF809D Hitchhiking in the Baltic States LIS、平衡树

    传送门 看到最长上升子序列肯定是DP 设\(f_i\)表示计算到当前,长度为\(i\)的最长上升子序列的最后一项的最小值,显然\(f_i\)是一个单调递增的序列. 转移:对于当前计算的元素\(x\), ...

  7. Luogu4700 CEOI2011 Traffic Tarjan、搜索

    传送门 题意:给出平面上$N$个点,它们一定在左下角为$(0,0)$,右上角为$(A,B)$的一个矩形内的整点上(包括边界),而且会给出$M$条呈直线的边,其中有有向边也有无向边,保证任意两条边不会在 ...

  8. C# 多线程 Parallel.For 和 For 谁的效率高?那么 Parallel.ForEach 和 ForEach 呢?

    还是那句话:十年河东,十年河西,莫欺少年穷. 今天和大家探讨一个问题:Parallel.For 和 For 谁的效率高呢? 从CPU使用方面而言,Parallel.For 属于多线程范畴,可以开辟多个 ...

  9. 【php增删改查实例】第二十一节 - 用户修改功能

    19.1 添加用户修改的按钮 打开userManage.html,找到新增按钮的地方: 我们不难发现,编辑按钮就差不多应该在新建用户的右边. 那么,假如我现在是新人,对这个项目本身就不太熟悉,那么我得 ...

  10. Centos7 -- glibc 升级失败、意外删除、故意删除后的处理方法

    第一部分:测试(如果不是想测试效果,可以直接跳到第三部分) 鉴于不久前 glibc-2.29 升级失败导致一系列的工具无法正常使用,‘’ 本着研究精神的我决定删除 glibc及其库文件 ,测试影响范围 ...