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. Android Dalvik 虚拟机

    简介 Android 平台虽然是使用java语言来开发应用程序,但Android程序却不是运行在标准java虚拟机上的.谷歌专门为Android平台设计了一套虚拟机来运行Android程序.它就是Da ...

  2. cmake 学习笔记(四)

    接前面的一二三,学习一下 CMakeCache.txt 相关的东西. CMakeCache.txt 可以将其想象成一个配置文件(在Unix环境下,我们可以认为它等价于传递给configure的参数). ...

  3. Co-prime(容斥)

    Co-prime Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total S ...

  4. IIS express 7.5 配置和多网站执行

    iis express7.5 支持xp 以上的操作系统,能够解决xp.iis的问题. 首先先下载安装iisexpress7.5地址是id=1038">点击打开链接下载完毕点击安装就可以 ...

  5. Phalcon框架中的另类使用

    不像传统的PHP框架,假设框架想被还有一个框架使用仅仅能通过rpc或是引入文件等的方式.Phalcon能够在其他框架中直接使用.这是因为Phalcon是以扩展的形式存在的,在server载入时会直接载 ...

  6. vmware时间不同步的问题

    请以管理员身份运行(root)

  7. Ural 1086 - Cryptography

    While preparing this problem set the jury has run into the following problem: it was necessary to se ...

  8. 无线网络wifi (WPA/WPA2)密码破解方法

    无线网络password破解WPA/WPA2教程 本教程用于探索无线路由安全漏洞,禁止用于非法用途,违者法律必究(与我无关) 在动手破解WPA/WPA2前,应该先了解一下基础知识,本文适合新手阅读 首 ...

  9. Java设计模式菜鸟系列(九)外观模式建模与实现

    转载请注明出处:http://blog.csdn.net/lhy_ycu/article/details/39805735 外观模式(Facade):是为了解决类与类之间的依赖关系的,像spring一 ...

  10. 关于DataGridViewComboBoxCell修改后提交数据源

    最近在项目遇到一个功能实现.是在DataGridView中DataGridViewComboboxColumn列绑定数据源, DisplayMember为数据表的Name列,ValueMember是数 ...