uva10253 Series-Parallel Networks
来源:互联网 发布:淘宝怎么查历史价格 编辑:程序博客网 时间:2024/05/29 16:40
In this problem you are expected to count two-terminal series-parallel
networks . These are electric networks considered topologically or
geometrically, that is, without the electrical properties of the
elements connected. One of the two terminals can be considered as the
source and the other as the sink . A two-terminal network will be
considered series-parallel if it can be obtained iteratively in the
following way: A single edge is two-terminal series-parallel. If G
1 and G 2 are two-terminal series-parallel, so is the network obtained
by identifying the sources and sinks, respectively (parallel
composition). If G 1 and G 2 are two-terminal series-parallel, so is
the network obtained by identifying the sink of G 1 with the source of
G 2 (series composition). Note here that in a series-parallel network
two nodes can be connected by multiple edges. 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 is also an equivalence operation. For example,
the following three networks are also equivalent: Now, given a number
N , you are expected to count the number of two-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 le contains an integer N (1 N 30)
specifying the number of edges in the network. A line containing a
zero for N terminates the input and this input need not be considered.
Output For each N in the input le print a line containing the number
of two-terminal series-parallel networks that can be obtained using
exactly N edges.
不断的串并联其实就是不断的合并边的过程,而且从最后一次回溯,每一层的串并联情况都相同,相邻层之间的串并联情况相反【否则就不分层了】。
这样其实就是一个正整数拆分,可以用动态规划解决。
用
其中
#include<cstdio>#include<cstring>#include<algorithm>using namespace std;#define LL long longconst int maxn=30;LL dp[35][35],ans[35];LL c(LL n,LL k){ double ret=1; LL i; for (i=n-k+1;i<=n;i++) ret*=i; for (i=1;i<=k;i++) ret/=i; return ret+0.5;}int main(){ int i,j,k,n; dp[0][0]=ans[0]=ans[1]=1; for (i=1;i<=maxn;i++) dp[0][i]=dp[1][i]=1; for (j=1;j<=maxn;j++) { for (i=2;i<=maxn;i++) for (k=0;k*j<=i;k++) dp[i][j]+=dp[i-k*j][j-1]*c(ans[j]+k-1,k); ans[j+1]=dp[j+1][j]; } while (scanf("%d",&n)&&n) printf("%lld\n",n==1?1:2*ans[n]);}
- uva10253 Series-Parallel Networks
- UVA10253 - Series-Parallel Networks(树形DP+(组合) _ 建模很好)(好题)
- Series-Parallel Networks UVA 10253
- uva 10253 - Series-Parallel Networks
- UVa 10253 Series-Parallel Networks
- uvaoj 10253 - Series-Parallel Networks
- UVA 10253Series-Parallel Networks
- Uva 10253 - Series-Parallel Networks 解题报告(递推)
- UVA 10253 - Series-Parallel Networks(数论+计数问题+递推)
- uva 10253 Series-Parallel Networks 树的性质,可重排列
- ACM: uva 10253 - Series-Parallel…
- Convolutional Networks for Images,Speech,and Time-series
- Recurrnet Neural Networks, Time series data and IoT
- Parallel
- 源码角度分析async的waterfull vs parallel vs series方法
- Series
- A Guide For Time Series Prediction Using Recurrent Neural Networks (LSTMs)
- A new boosting algorithm for improved time-series forecasting with recurrent neural networks
- web前端学习--html
- Android的兼容性
- 软件架构乱谈—SSH框架
- 7路PWM产生程序阅读
- SublimeText3 插件开发记录 --- 划词翻译
- uva10253 Series-Parallel Networks
- Lua学习笔记(基础一)
- [BZOJ3238][Ahoi2013]差异(后缀自动机||后缀数组)
- 康复训练3
- gensim工具包
- 求n-m之间所有数额和
- Minimum Path Sum
- memset用法详解
- RecycleView的简单实现