zoukankan      html  css  js  c++  java
  • 题解 CH5E07 【划分大理石】

    题目链接:Link

    Problem

    Solution

    这题好难啊只需要判断能否拼接出sum/2即可,因为剩下的必然也是sum/2。。。
    然后就可以愉快地多重背包了。。。

    Code

    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    using namespace std;
    const int maxn=20005;
    int a[7],f[maxn*6],tot,Q[maxn*6],L,R;
    void DP(int v,int t)
    {
    	for(int s=0;s<v;s++)
    	{
    		Q[L=R=1]=s;
    		for(int j=s+v;j<=tot;j+=v)
    		{
    			while(L<=R&&(j-Q[L])/v>t) L++;
    			if(L<=R) f[j]=f[Q[L]];
    			while(L<=R&&f[j]>=f[Q[R]]) R--;
    			Q[++R]=j;
    		}
    	}
    }
    int main()
    {
    	#ifdef local
    	freopen("pro.in","r",stdin);
    	#endif
    	while(true)
    	{
    		tot=0;
    		for(int i=1;i<=6;i++) { scanf("%d",&a[i]); tot+=a[i]*i; }
    		if(tot==0) return 0;
    		if(tot&1) { puts("Can't"); continue; }
    		memset(f,0,sizeof(f));
    		f[0]=1; tot/=2;
    		for(int i=1;i<=6;i++) DP(i,a[i]);
    		puts(f[tot]?"Can":"Can't");
    	}
    	return 0;
    }
    
  • 相关阅读:
    step_by_step_ABP规约模式
    阅读书单
    关于我
    友情链接
    数据夜话之大数据OLAP数据库概览
    Spark实战
    StormDRPC流程解读
    Curator源码阅读
    Storm使用总结
    JNI相关使用记录
  • 原文地址:https://www.cnblogs.com/happyZYM/p/11518414.html
Copyright © 2011-2022 走看看