• BZOJ 1037 生日聚会(神DP)


    这题的DP很难想,定义dp[i][j][a][b]表示用了i个男生,j个女生,任一连续的后缀区间内,男生比女生最多多a人,女生比男生最多多b人。

    转移就是显然了。

    # include <cstdio>
    # include <cstring>
    # include <cstdlib>
    # include <iostream>
    # include <vector>
    # include <queue>
    # include <stack>
    # include <map>
    # include <set>
    # include <cmath>
    # include <algorithm>
    using namespace std;
    # define lowbit(x) ((x)&(-x))
    # define pi acos(-1.0)
    # define eps 1e-9
    # define MOD 12345678
    # define INF 1000000000
    # define mem(a,b) memset(a,b,sizeof(a))
    # define FOR(i,a,n) for(int i=a; i<=n; ++i)
    # define FO(i,a,n) for(int i=a; i<n; ++i)
    # define bug puts("H");
    # define lch p<<1,l,mid
    # define rch p<<1|1,mid+1,r
    # define mp make_pair
    # define pb push_back
    typedef pair<int,int> PII;
    typedef vector<int> VI;
    # pragma comment(linker, "/STACK:1024000000,1024000000")
    typedef long long LL;
    int Scan() {
        int res=0, flag=0;
        char ch;
        if((ch=getchar())=='-') flag=1;
        else if(ch>='0'&&ch<='9') res=ch-'0';
        while((ch=getchar())>='0'&&ch<='9')  res=res*10+(ch-'0');
        return flag?-res:res;
    }
    void Out(int a) {
        if(a<0) {putchar('-'); a=-a;}
        if(a>=10) Out(a/10);
        putchar(a%10+'0');
    }
    const int N=10005;
    //Code begin...
    
    int dp[155][155][25][25];
    
    int main ()
    {
        int n, m, k;
        scanf("%d%d%d",&n,&m,&k);
        dp[0][0][0][0]=1;
        FOR(i,0,n) FOR(j,0,m) FOR(l1,0,k) FOR(l2,0,k) {
            dp[i+1][j][l1+1][max(l2-1,0)]=(dp[i+1][j][l1+1][max(l2-1,0)]+dp[i][j][l1][l2])%MOD;
            dp[i][j+1][max(l1-1,0)][l2+1]=(dp[i][j+1][max(l1-1,0)][l2+1]+dp[i][j][l1][l2])%MOD;
        }
        int ans=0;
        FOR(i,0,k) FOR(j,0,k) ans=(ans+dp[n][m][i][j])%MOD;
        printf("%d
    ",ans);
        return 0;
    }
    View Code
  • 相关阅读:
    关于分区索引与全局索引性能比较的示例
    演示DML操作导致位图索引锁定的简单示例
    show_spce存储过程的使用
    silverlight 滚动文字
    数据绑定
    silverlight 导航总结<二>待续
    Silverlight应用
    silverlight导航总结<一>应用传统的批改容器的Content或者是Child等内容来实现导航
    控件之布局控件
    silverlight 如何编辑控件模板?以制作圆形按钮为例
  • 原文地址:https://www.cnblogs.com/lishiyao/p/6498445.html
Copyright © 2020-2023  润新知