A:非常裸的dp。

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int read()
{
int x=,f=;char c=getchar();
while (c<''||c>'') {if (c=='-') f=-;c=getchar();}
while (c>=''&&c<='') x=(x<<)+(x<<)+(c^),c=getchar();
return x*f;
}
#define P 1000000007
#define N 32
int a,b,c,d,f[N][N][N][N][];
void inc(int &x,int y){x+=y;if (x>=P) x-=P;}
int main()
{
freopen("count.in","r",stdin);
freopen("count.out","w",stdout);
a=read(),b=read(),c=read(),d=read();
f[][][][][]=f[][][][][]=f[][][][][]=f[][][][][]=;
for (int i=;i<a+b+c+d;i++)
for (int x=;x<=a;x++)
for (int y=;y<=b;y++)
for (int z=;z<=c;z++)
{
int t=i-x-y-z;
if (t>d) continue;
for (int p=;p<;p++)
for (int q=;q<;q++)
if (p!=q)
{
if (q==&&x<a) inc(f[x+][y][z][t][q],f[x][y][z][t][p]);
if (q==&&y<b) inc(f[x][y+][z][t][q],f[x][y][z][t][p]);
if (q==&&z<c) inc(f[x][y][z+][t][q],f[x][y][z][t][p]);
if (q==&&t<d) inc(f[x][y][z][t+][q],f[x][y][z][t][p]);
}
}
cout<<((f[a][b][c][d][]+f[a][b][c][d][])%P+(f[a][b][c][d][]+f[a][b][c][d][])%P)%P;
return ;
}

  B:非常裸的组合。我又学傻了第一眼居然容斥还好拍了。

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int read()
{
int x=,f=;char c=getchar();
while (c<''||c>'') {if (c=='-') f=-;c=getchar();}
while (c>=''&&c<='') x=(x<<)+(x<<)+(c^),c=getchar();
return x*f;
}
#define N 200010
#define P 1000000007
int n,m,k,ans=,fac[N],inv[N];
int C(int n,int m){return 1ll*fac[n]*inv[m]%P*inv[n-m]%P;}
int main()
{
freopen("array.in","r",stdin);
freopen("array.out","w",stdout);
n=read(),m=read(),k=read();
fac[]=;for (int i=;i<=n+m;i++) fac[i]=1ll*fac[i-]*i%P;
inv[]=inv[]=;for (int i=;i<=n+m;i++) inv[i]=P-1ll*(P/i)*inv[P%i]%P;
for (int i=;i<=n+m;i++) inv[i]=1ll*inv[i]*inv[i-]%P;
if (m-k&) {cout<<;return ;}
cout<<1ll*C(n,k)*C((m-k>>)+n-,n-)%P;
return ;
}

  C:非常裸的meet in the middle。

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int read()
{
int x=,f=;char c=getchar();
while (c<''||c>'') {if (c=='-') f=-;c=getchar();}
while (c>=''&&c<='') x=(x<<)+(x<<)+(c^),c=getchar();
return x*f;
}
#define N 300010
#define ll long long
int n,b[];
ll a[][N],l,r,ans,m;
void dfs(int k,int n,int p,ll s)
{
if (k>n) a[p][++a[p][]]=s;
else
{
dfs(k+,n,p,s);
dfs(k+,n,p,s+b[k]);
}
}
ll calc(ll k)
{
ll s=;int x=a[][];
for (int i=;i<=a[][];i++)
{
while (x&&a[][x]+a[][i]>k) x--;
s+=x;
}
return s;
}
int main()
{
freopen("subset.in","r",stdin);
freopen("subset.out","w",stdout);
n=read();cin>>m;
for (int i=;i<=n;i++) r+=(b[i]=read());
dfs(,n>>,,);
dfs((n>>)+,n,,);
sort(a[]+,a[]+a[][]+);
sort(a[]+,a[]+a[][]+);
while (l<=r)
{
ll mid=l+r>>;
if (calc(mid)>=m) ans=mid,r=mid-;
else l=mid+;
}
cout<<ans;
return ;
}

  result:300 rank1

Contest 3的更多相关文章

  1. Programming Contest Problem Types

        Programming Contest Problem Types Hal Burch conducted an analysis over spring break of 1999 and ...

  2. hdu 4946 2014 Multi-University Training Contest 8

    Area of Mushroom Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) ...

  3. 2016 Multi-University Training Contest 2 D. Differencia

    Differencia Time Limit: 10000/10000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Tot ...

  4. 2016 Multi-University Training Contest 1 G. Rigid Frameworks

    Rigid Frameworks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) ...

  5. hdu-5988 Coding Contest(费用流)

    题目链接: Coding Contest Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Ot ...

  6. ZOJ 3703 Happy Programming Contest

    偏方记录背包里的物品.....每个背包的价值+0.01 Happy Programming Contest Time Limit: 2 Seconds      Memory Limit: 65536 ...

  7. 2012 Multi-University Training Contest 9 / hdu4389

    2012 Multi-University Training Contest 9 / hdu4389 打巨表,实为数位dp 还不太懂 先这样放着.. 对于打表,当然我们不能直接打,这里有技巧.我们可以 ...

  8. 2014 Multi-University Training Contest 9#11

    2014 Multi-University Training Contest 9#11 Killing MonstersTime Limit: 2000/1000 MS (Java/Others)   ...

  9. 2014 Multi-University Training Contest 9#6

    2014 Multi-University Training Contest 9#6 Fast Matrix CalculationTime Limit: 2000/1000 MS (Java/Oth ...

  10. 校际联合Contest

    每次开一个坑都像是重新被碾压的预感 最近的新闻,以前很喜欢乔任梁的<复活>...然后他就死了...感觉我再多愁善感一点的话...就要悲伤逆流成河了吧... Contest 09/24(乐滋 ...

随机推荐

  1. 浅入tcp

    1.认识TCP tcp协议是传输层协议,它的最主要的3个特点是面向连接.可靠保证.基于字节流.当应用层把数据给tcp层时,注意如果数据大于MSS是要在tcp层进行分段的.tcp协议为了保证不丢包会给每 ...

  2. 人脸识别引擎SeetaFaceEngine简介及在windows7 vs2013下的编译

    SeetaFaceEngine是开源的C++人脸识别引擎,无需第三方库,它是由中科院计算所山世光老师团队研发.它的License是BSD-2. SeetaFaceEngine库包括三个模块:人脸检测( ...

  3. OpenStack入门篇(七)之认证服务Keystone

    一.Keystone的概述 Keystone是Openstack的组件之一,用于为Openstack家族中的其它组件成员提供统一的认证服务,包括身份验证,令牌的发放和校验,服务列表,用户权限的定义等. ...

  4. Drupal8 新建第一个模块

    参考: https://www.drupal.org/developing/modules/8 https://www.drupal.org/node/1915030 https://www.drup ...

  5. python-创建进程的三种方式

    目录 1,os.fork() 方法 2,Process方法 3,Pool方法 1,os.fork() 方法 import os ret = os.fork() if ret == 0: #子进程 pr ...

  6. PHPCMS V9 的手机门户wap绑定单页面

    当前的Phpcms V9手机网站的设置还有点弱,绑定的栏目不能设置选择模板,而且不能绑定单页面page.不过可以自定义做到绑定单页面page这一个功能:1.修改phpcms\modules\wap\i ...

  7. 请教Amazon FBA里面Label Service, Stickerless, Commingled Inventory是什么意思?

    Accept Label Service接受标签服务,选择了以后下面的操作中会有一个让您打印标签的流程,您就可以按照FBA流程提示进行每一步标签服务的操作. Accept Stickless, Com ...

  8. Python常用模块之hashlib

    Python里面的hashlib模块提供了很多加密的算法,这里介绍一下hashlib的简单使用事例,用hashlib的md5算法加密数据 import hashlib hash = hashlib.m ...

  9. python 标准日志模块loging 及日志系统实例

    本文出处:https://www.cnblogs.com/goodhacker/p/3355660.html#undefined python的标准库里的日志系统从Python2.3开始支持.只要im ...

  10. Scrum立会报告+燃尽图(十月三十日总第二十一次)

    此作业要求参见:https://edu.cnblogs.com/campus/nenu/2018fall/homework/2290 项目地址:https://git.coding.net/zhang ...