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 ...
随机推荐
- 【UVA 11404】Palindromic Subsequence
UVA 11404 我用了最暴力的做法:考虑\(dp[i][j]\)表示\(S[i..j]\)的最长回文子序列的长度以及字典序最小的那个. 然后转移的时候如下处理:首先\(dp[i][j]\)要取\( ...
- Java多线程编程模式实战指南之Promise模式
Promise模式简介(转) Promise模式是一种异步编程模式 .它使得我们可以先开始一个任务的执行,并得到一个用于获取该任务执行结果的凭据对象,而不必等待该任务执行完毕就可以继续执行其他操作.等 ...
- curl命令行
curl命令行--强大的工具.通过各种参数,支持各种方式. 写几个常用的命令: 请求到的网站html curl http://www.baidu.com 比如想在命令行上请求一个接口,post过去几个 ...
- 安全提示:IIS不要开启“WebDAV”扩展(转载)
在IIS设置里,有一个“Web服务扩展”的设置,其中包括“WebDAV”扩展.许多人都不明白,这个“WebDAV”扩展是干嘛用的,要不要开启呢?有不少人的想法是“开启吧,以免影响网站运行,启用总比不启 ...
- mybatis 反射bean规则
1,根据查询字段名,寻找 bean变量名设置,变量可为私有属性 2,根据查询字段名 set方法名,设置bean属性 此方法 为 ‘set‘+字段名,大小写忽略,即 方法set后面第一个字母可以是大小写 ...
- [Spark][Python]Spark 访问 mysql , 生成 dataframe 的例子:
[Spark][Python]Spark 访问 mysql , 生成 dataframe 的例子: mydf001=sqlContext.read.format("jdbc").o ...
- vue 路由拦截、axios请求拦截
路由拦截 项目中,有些页面需要登录后才能进入,例如,在某页面A,用户在操作前需要先进入登录页(此时需要将上一页的地址(/survey/start)作为query存入login页面的地址中,如: htt ...
- SC1243sensor噪点问题调试
接手一块SC1243sensor的板子调试,仔细核对了原理图和PCB发现,PCB不是很好,电源处理不够好,但是出图了,问题是有噪点,麻点,根据经验要求软件修改了PCLK的极性噪点消失,问题解决. 1: ...
- Individual Project 1 总结
题目: http://www.cnblogs.com/jiel/p/3978727.html 1. 估计时间: ① 遍历目录找到所有文本文件 3天 ② 编写统计词频的函数 排序的函数 并输出到文件 2 ...
- Scrum Meeting day 4
第四次会议 No_00:工作情况 No_01:任务说明 待完成 已完成 No_10:燃尽图 No_11:照片记录 待更新 No_100:代码/文档签入记录 No_101:出席表 ...