High Speed Trains

Time Limit: 4000/2000MS (Java/Others)Memory Limit: 128000/64000KB (Java/Others)

Problem Description

The kingdom of Flatland has n cities. Recently the king of Flatland visited Japan and was amazed by high speed trains Shinkansens going all around the country. Therefore he decided to build the system of high
speed trains in Flatland.

Each high speed train line will be bidirectional and connect exactly two different cities of Flatland. Although there is actually no need of high speed trains in Flatland, the king ordered that there must
be at least one high speed train line from each city of Flatland.

      The minister of transportation told the king that there are several train system satisfying his requirements. The king was amazed by the fact and asked the minister to count the number of possible systems.

      Help the minister to calculate the number of train systems.

Input

      The input file contains one integer number n (2 ≤ n ≤ 100)

Output

      Output one integer number — the number of different train systems that can be arranged in Flatland.

Sample Input

4

Sample Output

41

题意:给出图的点数n,要求的是由这n个点能够构成多少种图,要满足每一个点至少有一条边相连,两点之间最多一条边。图能够不连通

思路:推公式题

            dp[n] = dp[n-1] * ( 2^(n-1) - 1 ) + C( n-1 , 1 ) * 2^(n-2) * dp[n-2] + C( n-1 , 2 ) * 2^(n-3) * dp[n-3] + ...... + C( n-1 , n-3 ) * 2^( 2 ) * dp[ 2 ] + 1

            要用大数

ASC(22)H(大数+推公式)的更多相关文章

  1. HDU 4873 ZCC Loves Intersection(JAVA、大数、推公式)

    在一个D维空间,只有整点,点的每个维度的值是0~n-1 .现每秒生成D条线段,第i条线段与第i维度的轴平行.问D条线段的相交期望. 生成线段[a1,a2]的方法(假设该线段为第i条,即与第i维度的轴平 ...

  2. sgu495:概率dp / 推公式

    概率题..可以dp也可以推公式 抽象出来的题目大意: 有 n个小球,有放回的取m次  问 被取出来过的小球的个数的期望 dp维护两个状态 第 i 次取出的是 没有被取出来过的小球的 概率dp[i] 和 ...

  3. hdu4507 数位dp+推公式

    推公式的能力需要锻炼.. /* dp的时候要存结构体 里面三个元素: cnt,就是满足条件的个数 sum1,就是满足条件的数字和 sum2,满足条件的数字平方和 推导过程:还是用记忆化搜索模板 dp[ ...

  4. 2017多校第7场 HDU 6128 Inverse of sum 推公式或者二次剩余

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6128 题意:给你n个数,问你有多少对i,j,满足i<j,并且1/(ai+aj)=1/ai+1/a ...

  5. SGU 495 Kids and Prizes:期望dp / 概率dp / 推公式

    题目链接:http://acm.sgu.ru/problem.php?contest=0&problem=495 题意: 有n个礼物盒,m个人. 最开始每个礼物盒中都有一个礼物. m个人依次随 ...

  6. hdu6061[NTT推公式] 2017多校3

    /*hdu6061[NTT推公式] 2017多校3*/ #include <bits/stdc++.h> using namespace std; typedef long long LL ...

  7. HDU6050: Funny Function(推公式+矩阵快速幂)

    传送门 题意 利用给出的式子求\(F_{m,1}\) 分析 直接推公式(都是找规律大佬) \(n为偶数,F_{m,1}=\frac{2(2^n-1)^{m-1}}3\) \(n为奇数,F_{m,1}= ...

  8. 【BZOJ1426】收集邮票 概率DP 论文题 推公式题

    链接: #include <stdio.h> int main() { puts("转载请注明出处[辗转山河弋流歌 by 空灰冰魂]谢谢"); puts("网 ...

  9. HDU 4870 Rating(概率、期望、推公式) && ZOJ 3415 Zhou Yu

    其实zoj 3415不是应该叫Yu Zhou吗...碰到ZOJ 3415之后用了第二个参考网址的方法去求通项,然后这次碰到4870不会搞.参考了chanme的,然后重新把周瑜跟排名都反复推导(不是推倒 ...

随机推荐

  1. nginx学习六 高级数据结构之双向链表ngx_queue_t

    1 ngx_queue_t简单介绍 ngx_queue_t是nginx提供的一个轻量级的双向链表容器,它不负责存储数据,既不提供数据的内存分配.它仅仅有两个指针负责把数据链入链表.它跟stl提供的qu ...

  2. Android 5.0五大安全特性

    全盘加密(Full Disk Encryption, FDE) 对所有闪存数据加密.性能下降较大 Nexus 6,Nexus 9无法关闭FDE 对于其它设备.Google推荐开启 多用户支持 4.2中 ...

  3. java的数据类型,几个java小程序

    1:求圆的面积 还好看了c++,不然直接看这课件还真是看不懂……加油吧 要从键盘读入数据可以用Scanner类的nextlnt()或者nextDouble()方法,首先创建Scanner类的一个实例, ...

  4. iOS判断字符串是否包含表情字符

    - (BOOL)isContainsEmoji:(NSString *)string { __block BOOL isEomji = NO; [, [string length]) options: ...

  5. A valid provisioning profile for this executable was not found.

  6. 用 Python 测试框架简化测试

    用 Python 测试框架简化测试 摘要:本文将向您介绍了三种流行 Python 测试框架(zope.testing,py.test,nose)的基本特性,并讨论新一代的测试风格. 最近出现了行业级的 ...

  7. csharp .net vb 复制图像

    .NET Compact Framework 不支持 Image.Clone 方法,可是仍能够复制图像和图像的某些部分.以下的演示例子演示怎样运行以下操作: 定义一个方法以创建位图. 定义一个重载方法 ...

  8. cocos2d-实现读取.plist文件(使用数组CCArray)

    学习札记之cocos2d-x2.1.1实现读取.plist文件(使用数组CCArray) <?xml version="1.0" encoding="UTF-8&q ...

  9. eclipse java快捷模板 快捷键大全

    建议没事研究研究自己吃饭的工具,俗话说工欲善其事必先利其器嘛. 首先,快捷键这种东西大家都会知道点,但是很少人重视javaEditorTemplate这块.先介绍下Template java编辑模板 ...

  10. 第三届蓝桥杯 c/c++真题

    第三届蓝桥杯真题 c/c++ 以下题目我自己也并不是所有的题目都是一次性就能做对或是有结题思路的.有些题目也是经过查证网上相关的资料或是参考了别人的代码和解题思路才做出来的.总的来看,这份题目考了很多 ...