• LOJ#6501. 「雅礼集训 2018 Day4」Cube 题解


    题目链接

    答案为 (inom{n}{m} imes 2^{n-m})

    证明1 :

    考虑枚举(m)维作为超立方体,令剩余的(n-m)维在(0/1)中任意选择,方案即为选出(m)维的方案和(n-m)维选择(0/1)的方案的乘积即(inom{n}{m} imes 2^{n-m})

    证明2 :

    首先 (f_{1,1} = 1,f_{1,x(x>1)} = 0.)

    对于 (f_{n(n>1),m},) 我们尝试寻找其递推式。

    不难发现我们要么是当前一维拿来确定,即在两个(n-1)维超立方体中找出(m-1)维超立方体的方案数,为 (f_{n-1,m-1}.)

    或者我们直接递归到两个子超立方体中,此时的答案为 (2f_{n-1,m}.)

    不难发现答案即为([x^m](2x+1)^n = inom{n}{m} imes 2^{n-m}.)

    code :

    #include <bits/stdc++.h>
    #define LL long long
    using namespace std;
    template <typename T> void read(T &x){
    	static char ch; x = 0,ch = getchar();
    	while (!isdigit(ch)) ch = getchar();
    	while (isdigit(ch)) x = x * 10 + ch - '0',ch = getchar();
    }
    inline void write(int x){if (x > 9) write(x/10); putchar(x%10+'0'); }
    const int P = 998244353,N = 100005;
    int fac[N],inv[N],nfac[N],pw[N];
    inline int C(int n,int m){ return (LL)fac[n] * nfac[m] % P * nfac[n-m] % P; }
    int main(){
    	int i;
    	fac[0] = nfac[0] = inv[0] = fac[1] = nfac[1] = inv[1] = pw[0] = 1; pw[1] = 2;
    	for (i = 2; i <= 100000; ++i)
    		pw[i] = pw[i-1] * 2 % P,fac[i] = (LL)fac[i-1] * i % P,inv[i] = (LL)(P-P/i) * inv[P%i] % P,nfac[i] = (LL)nfac[i-1] * inv[i] % P;
    	int T,n,m;
    	read(T);
    	while (T--) read(n),read(m),write((LL)C(n,m) * pw[n-m] % P),putchar('
    ');
    	return 0;
    }
    
  • 相关阅读:
    pdp,ppp,tcpip,socket联系
    EC20 AT指令
    pdp ppp
    安装 FreeSwitch PBX
    PCMA和PCMU编码带宽计算
    gdb使用symbol文件调试程序
    freeswitch 常用配置
    如何管理分布式团队
    测试环境的简单理解
    六个节点三主三从Redis集群最简单搭建方法
  • 原文地址:https://www.cnblogs.com/s-r-f/p/13620770.html
Copyright © 2020-2023  润新知