Uva 10253 - Series-Parallel Networks (计数+DP)

本文介绍了一种利用动态规划算法解决串并联网络计数问题的方法。串并联网络包含源和汇两个终端,通过递归定义进行构建。文章详细解释了如何通过构建特定的树形结构来统计具有固定数量边的网络数目。

In this problem you are expected to counttwo-terminal series-parallel networks. These are electric networks consideredtopologically or geometrically, that is, without the electrical properties ofthe elements connected. One of the two terminals can be considered as thesource and the other as the sink. A two-terminal network will be consideredseries-parallel if it can be obtained iteratively in the following way:

• A single edge is two-terminal series-parallel.

• If G1 and G2 are two-terminalseries-parallel, so is the network obtained by identifying the sources andsinks, respectively (parallel composition).

• If G1 and G2 are two-terminalseries-parallel, so is the network obtained by identifying the sink of G1 withthe source of G2 (series composition).

 Notehere that in a series-parallel network two nodes can be connected by multipleedges. Moreover, networks are regarded as equivalent, not only topologically,but also when interchange of elements in series brings them into congruence;otherwise stated, series interchange is an equivalence operation. For example,the following three networks are equivalent: Similarly, parallel interchange isalso an equivalence operation. For example, the following three networks arealso equivalent: Now, given a number N, you are expected to count the number oftwo-terminal series parallel networks containing exactly N edges. For example,for N = 4, there are exactly 10 series-parallel networks as shown below:

 

Input

Each line of the input file contains aninteger N (1 ≤ N ≤ 30) specifying the number of edges in the network. A linecontaining a zero for N terminates the input and this input need not beconsidered.

 

Output

For each N in the input file print a linecontaining the number of two-terminal series-parallel networks that can beobtained using exactly N edges.

 

Sample Input

1

4

15

0

 

Sample Output

1

10

1399068

 

【题意】

串并联网络有n个端点,一个叫源,一个叫汇,递归定义:

1.一条单独的边是串并联网络

2.若G1,G2是串并联网络,把它们的源和汇连在一起也能得到串并联网络(并联)

3.若G1,G2是串并联网络,把G1的汇和G2的源连在一起也能得到串并联网络(串联)

串并联网络中串联或并联在一起的各个部分可以互相调换顺序,即只算一种情况。给定正整数n,统计共有多少个n条边的串并联网络。

 

【思路】

   书上讲的动态规划思路感觉特别神,自己做是肯定想不出来的。每个串并联网络都可以看成是一棵树,并联或串联是非叶子结点,单边是叶子结点,所以这道题问的就是符合:具有n个叶子结点且每个非叶子结点至少有两个子结点(由至少两部分串联或并联)的树的数目f(n),乘以2得所求结果(根结点为串联或并联决定了两种不同的网络)

   如果要直接求解f(n)的话,那么就要枚举n的所有整数划分,比如枚举到n=24,24=(4+4+4)+(6+6)时,结果就要加上C(f(4)+3-1,3)*f(f(6)+2-1,2),这是一个可重复选择的组合问题。现在假设dp(i,j) 表示子树最多有i个叶节点,当前树共有j个叶节点时对应树的数量,那么答案f(n)=dp(n-1,n),而dp(i,j)=sum{dp(i-1,j-p*i)*C(f(i)+p-1,p)|p>=0,p*i<=j},这样就可以递推结果了,但是边界条件比较复杂dp(i,0)=1(i>=0),dp(i,1)=1(i>=1),dp(0,i)=0(i>=1)


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const int maxn = 50;

int n;
ll dp[maxn][maxn];//dp[i][j]表示子树最多有i个叶节点,当前树共有j个叶节点时对应树的数量 
ll f[maxn];//f[n]记录n条边的解 

ll C(ll n, ll m) {//计算组合数 
	double ans = 1;
	for (int i = 0; i < m; i++) ans *= n - i;
	for (int i = 0; i < m; i++) ans /= i + 1;
	return ll(ans + 0.5);
} 

void init() {
	f[1] = 1;
	memset(dp, 0, sizeof(dp));
	
	for (int i = 0; i <= 35; i++) dp[i][0] = 1;
	for (int i = 1; i <= 35; i++) { dp[i][1] = 1; dp[0][i] = 0;}
	
	for (int i = 1; i <= 35; i++) {
		for (int j = 2; j <= 35; j++) {
			dp[i][j] = 0;
			for (int p = 0; p*i <= j; p++) {
				dp[i][j] += C(f[i]+p-1, p)*dp[i - 1][j - p*i];
			}
		}
		f[i + 1] = dp[i][i + 1];
	}
}

int main() {
	init();
	while (scanf("%d", &n) == 1 && n) {
		if (1 == n) { printf("1\n"); continue; }
		printf("%lld\n", 2*f[n]);
	}
	return 0;
}


转载于:https://www.cnblogs.com/wafish/p/10465468.html

### MATLAB Simulink 中多径信道模型 (LTI) 的建模信号处理 #### 多径信道模型的构建 在 MATLAB 和 Simulink 中,可以通过 `comm.RayleighChannel` 或者自定义线性时不变 (LTI) 系统来模拟多径信道。对于 LTI 模型,可以利用传递函数或者状态空间表示法描述系统的动态特性[^1]。 以下是基于 LTI 的多径信道建模方法: ```matlab % 定义一个多径信道的冲激响应 h(t) h = [0.8, 0.3, -0.2]; % 对应三个路径的增益 Ts = 1e-6; % 符号间隔时间 fs = 1/Ts; % 采样频率 % 创建离散时间滤波器对象 channelFilter = dsp.FIRFilter('Numerator', h); % 测试输入信号 inputSignal = randn(1, 100); % 高斯白噪声作为测试信号 % 经过多径信道后的输出信号 outputSignal = channelFilter(inputSignal); ``` 通过上述代码片段,可以在 MATLAB 中创建一个简单的多径信道模型并观察其效果[^2]。 --- #### 信道参数提取 为了从接收到的信号中估计信道参数(例如路径延迟和增益),通常采用最小二乘法 (LS) 或其他更复杂的算法如 MUSIC、ESPIRIT 等。Simulink 提供了工具箱支持这些功能,具体如下所示: ```matlab % 使用 LS 方法进行信道估计 estimatedH = lscov(toeplitz(outputSignal), inputSignal); ``` 此部分涉及矩阵运算以及统计学原理,在实际应用中可能需要进一步优化以适应不同场景下的性能需求[^3]。 --- #### 均衡模块设计 —— MMSE 均衡器 MMSE (Minimum Mean Square Error)均衡是一种常见的技术手段用于补偿由多径效应引起的 ISI 干扰。下面展示如何在 Simulink 中实现该过程的一个简化版本: 1. **导入数据源**:将经过多径信道传输的数据流引入到仿真环境中; 2. **配置均衡器结构**:选用 FIR 类型或其他适合的形式; 3. **调整权重系数**:依据目标准则计算最优解向量 w*; 示意图可以用以下方式呈现出来: ```plaintext Input Signal --> Channel Model --> Received Data --> Equalizer Block --> Output Estimate ``` 其中,“Equalizer Block”的内部逻辑可参照下述伪代码编写而成: ```matlab function y_estimated = mmse_equalize(r, H_matrix, noise_power) Rrr_inv = inv(H_matrix' * H_matrix + noise_power .* eye(size(H_matrix))); weights = Rrr_inv * H_matrix'; y_estimated = weights * r; end ``` 注意这里的变量定义需匹配具体的物理意义,并且考虑到数值稳定性问题建议加入正则化项防止奇异情况发生[^4]。 --- #### OFDM 示例教程 针对 OFDM 系统中的多径影响分析及其对应的解决方案探讨,则可以从以下几个方面展开讨论: - IFFT/FFT 运算单元的设计原则; - CP 插入机制的作用机理说明; - 同步捕获环节的关键考量因素概述等等... 完整的工作流程图大致如下所列: ```plaintext Data Source -> Serial-to-Parallel Conversion -> Modulation Mapping -> IFFT Operation -> Cyclic Prefix Addition -> Parallel-to-Series Transformation -> Transmit Filter & Upconversion ``` 此同时也要记得考虑接收端相应的逆操作步骤安排合理顺序完成整个链路闭环验证工作[^5]。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值