SP5973 SELTEAM - Selecting Teams
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的更多相关文章
- spoj5973
SP5973 SELTEAM - Selecting Teams #include <bits/stdc++.h> using namespace std; typedef long lo ...
- End up with More Teams UVA - 11088
End up with More Teams Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %llu ...
- Rnadom Teams
Rnadom Teams 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.actioncid=88890#problem/B 题目: Descript ...
- poj 2239 Selecting Courses (二分匹配)
Selecting Courses Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8316 Accepted: 3687 ...
- 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 ...
- 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 ...
- timus 1106 Two Teams(二部图)
Two Teams Time limit: 1.0 secondMemory limit: 64 MB The group of people consists of N members. Every ...
- CF478 B. Random Teams 组合数学 简单题
n participants of the competition were split into m teams in some manner so that each team has at le ...
- Jmeter-Maven-Plugin高级应用:Selecting Tests To Run
地址:https://github.com/jmeter-maven-plugin/jmeter-maven-plugin/wiki/Advanced-Configuration Selecting ...
随机推荐
- PAT A1010 Radix (25 分)——进制转换,二分法
Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The an ...
- 【Codeforces 1137B】Camp Schedule
Codeforces 1137 B 题意:给两个串\(S\).\(T\),问将\(S\)中字符任意调换后出现\(T\)次数最多的方案. 思路:我们首先考虑怎么样放\(T\)才是最优的.我们直观上考虑前 ...
- C++ 预处理器
直接上代码 1.#define 预处理 #include <iostream> using namespace std; #define PI 3.14159 int main () { ...
- at android.view.Surface.unlockCanvasAndPost(Native Method)
at android.view.Surface.unlockCanvasAndPost(Native Method) 在绘制动画特效的时候点击back键会报以上异常. 主要原因:当点击back按钮时A ...
- node 文件操作
对文件的各种操作,使用姿势如下 文件操作单例 @example fu.exist(file); //是否存在 fu.copy(file, 'new-path'); //复制到某个新目录 fu.move ...
- day87
分页器 PageNumberPagination(普通分页器) 说明: 配置分页器的中最大显示个数(也可在setting中做全局配置) page.page_size = 2 REST_FRAMEWOR ...
- java算法----排序----(6)希尔排序(最小增量排序)
package log; public class Test4 { /** * java算法---希尔排序(最小增量排序) * * @param args */ public static void ...
- Luogu2469 SDOI2010 星际竞速 费用流
传送门 发现它的本质是求一个费用最小的路径覆盖 最小路径覆盖是网络流23题中的一个比较典型的模型 所以考虑相似的建边 因为每一个点要恰好经过一次,是一个有上下界的网络流,故拆点,星球\(i\)拆成\( ...
- 使用sklearn进行K_Means聚类算法
首先附上官网说明 [http://scikit-learn.org/stable/modules/generated/sklearn.cluster.KMeans.html#examples-usin ...
- Jmeter(三十二)_搭建本地接口自动化环境
我们在学习接口自动化的时候,最理想的状态是在公司有项目可以操作.大部分时候我们并没有可以练习的项目,因此练习接口无从谈起,只能找一些开放的api来练一练,但是这样并不能提高我们的技术.因此我们需要搭建 ...