Everything Is Generated In Equal Probability \[ Time Limit: 1000 ms\quad Memory Limit: 131072 kB \] 题意 给出一个 \(N\),以相等的概率生成 \(n\) 且 \(n \in [1, N]\),在以相等的概率生成长度为 \(n\) 的数组,最后将生成的数组扔到 \(CALCULATE\) 函数并返回一个数,问这个数的期望. 思路 先解释一下样例是怎么得来的. 令 \(dp[array]\) 表示…
Problem Description One day, Y_UME got an integer N and an interesting program which is shown below: Y_UME wants to play with this program. Firstly, he randomly generates an integer n∈[1,N] in equal probability. And then he randomly generates a permu…
题意: 给定一个N,随机从[1,N]里产生一个n,然后随机产生一个n个数的全排列,求出n的逆序数对的数量,加到cnt里,然后随机地取出这个全排列中的一个非连续子序列(注意这个子序列可以是原序列),再求出这个子序列的逆序数对,加到cnt里,重复这个过程,直到最后取出的为空. 题解: 先不考虑第一步随机从[1,N]里产生一个n,只考虑n给定的情况,求出了f[n],那么最后的结果就是 $  ans[N]=\frac{\sum_{n=1}^N f[n]}{N} $ 赛时和队友利用找规律法和暴力模拟法推出…
题意:给定一个N,随机从[1,N]里产生一个n, 然后随机产生一个n个数的全排列,求出n的逆序数对的数量并累加ans, 然后随机地取出这个全排列中的一个子序列,重复这个过程,直到为空,求ans在模998244353下的期望 思路:期望仅与长度有关,随手推一下式子 听说有通项公式 #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned int uint; typedef unsigne…
Problem Desciption: 百度翻译后的汉化: 参见博客:https://www.cnblogs.com/zxcoder/p/11253099.html https://blog.csdn.net/Cassie_zkq/article/details/97255683https://blog.csdn.net/Cassie_zkq/article/details/97255683…
---------------------------------------步履不停,奋勇前进! ------------------------难度真的是蛮大丫!后序补充!…
计算一对逆序对的贡献,即在n个数期望要删多少步才能删掉其中的两个数,设f(n)表示此时的期望,则有方程$f[n]=3/4+(\sum_{i=2}^{n}f[i]\cdot c(n-2,i-2))/2^n$,手算(打表)得到f[i]=4/3(代入成立),因此$ans=\sum_{i=1}^{n}(i-1)i/3=1/3(n(n+1)(2n+1)/6-n(n+1)/2)=(n-1)(n+1)/9$ 1 #include<bits/stdc++.h> 2 using namespace std; 3…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4405 Aeroplane chess Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others) 问题描述 Hzz loves aeroplane chess very much. The chess map contains N+1 grids labeled from 0 to N. Hzz s…
Aeroplane chess Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5230    Accepted Submission(s): 3290 Problem Description Hzz loves aeroplane chess very much. The chess map contains N+1 grids lab…
2019 杭电多校 7 1011 题目链接:HDU 6656 比赛链接:2019 Multi-University Training Contest 7 Problem Description Cuber QQ always envies those Kejin players, who pay a lot of RMB to get a higher level in the game. So he worked so hard that you are now the game design…
HDOJ(HDU).4508 湫湫系列故事――减肥记I (DP 完全背包) 题意分析 裸完全背包 代码总览 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #define nmax 100005 #define nn 105 using namespace std; int dp[nmax]; struct item{ int hap; int kal…
题目:http://poj.org/problem?id=2096 题目好长...意思就是每次出现 x 和 y,问期望几次 x 集齐 n 种,y 集齐 s 种: 所以设 f[i][j] 表示已经有几种,转移一下即可. 代码如下: #include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef double db; ; int n,s; db f[xn][xn]; in…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3853 题意: 有一个n*m的网格. 给出在每个格子时:留在原地.向右走一格,向下走一格的概率. 每走一格会消耗2点体力. 问你从(1,1)到达终点(n,m)消耗体力的期望. 题解: 表示状态: dp[i][j] = rest steps(剩余路程花费体力的期望) i,j:现在的位置 找出答案: ans = dp[0][0] 如何转移: 期望dp的套路:考虑子期望... now: dp[i][j] 能…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6656 题意: 有 1~n 个等级,你现在是1级,求升到n级的花费期望.会给你n个条件(i~i+1级升级所需花费,升级成功概率a/b,失败的话降为x级). 思路: 期望DP我一般不怎么会,一般都是从 dp[n] 开始转移到 dp[0] 的,但是这题是简单题,从1到n递推就行了(但是赛场是就是不会做). 我们设 dp[i] 是从 dp[i-1] 到 dp[i] 所需的花费期望值. 然后要知道有 a/b…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4418 Time travel Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others) 问题描述 Agent K is one of the greatest agents in a secret organization called Men in Black. Once he needs to…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=3853 LOOPS Time Limit: 15000/5000 MS (Java/Others)Memory Limit: 125536/65536 K (Java/Others) 问题描述 Akemi Homura is a Mahou Shoujo (Puella Magi/Magical Girl). Homura wants to help her friend Madoka save t…
任意门:http://acm.hdu.edu.cn/showproblem.php?pid=5723 Abandoned country Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 7573    Accepted Submission(s): 1850 Problem Description An abandoned country…
http://acm.hdu.edu.cn/showproblem.php?pid=5723 Abandoned country Problem Description   An abandoned country has n(n≤100000) villages which are numbered from 1 to n. Since abandoned for a long time, the roads need to be re-built. There are m(m≤1000000…
太吊了,反正我不会 /* HDU 4035 dp求期望的题. 题意: 有n个房间,由n-1条隧道连通起来,实际上就形成了一棵树, 从结点1出发,开始走,在每个结点i都有3种可能: 1.被杀死,回到结点1处(概率为ki) 2.找到出口,走出迷宫 (概率为ei) 3.和该点相连有m条边,随机走一条 求:走出迷宫所要走的边数的期望值. 设 E[i]表示在结点i处,要走出迷宫所要走的边数的期望.E[1]即为所求. 叶子结点: E[i] = ki*E[1] + ei*0 + (1-ki-ei)*(E[fa…
Problem Description Rompire is a robot kingdom and a lot of robots live there peacefully. But one day, the king of Rompire was captured by human beings. His thinking circuit was changed by human and thus became a tyrant. All those who are against him…
The more, The Better Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6324    Accepted Submission(s): 3722 Problem Description ACboy很喜欢玩一种战略游戏,在一个地图上,有N座城堡,每座城堡都有一定的宝物,在每次游戏中ACboy允许攻克M个城堡并获得里面的宝物…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5781 ATM Mechine Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) 问题描述 Alice is going to take all her savings out of the ATM(Automatic Teller Machine). Alice forget how m…
HDU 3920   Clear All of Them I 题目是说有2n个敌人,现在可以发n枚炮弹,每枚炮弹可以(可以且仅可以)打两个敌人,每一枚炮弹的花费等于它所行进的距离,现在要消灭所有的敌人,问最少花费是多少(反正题意大概就是这样啦,知道怎么回事就好了,解释不清了) 一看到n<=10而且又是在DP专题里的,就知道这个显然是状压DP,由于有2n个敌人,所以状态表示由当前状态再打两个人来转移, 10000100表示打了这两个敌人的最小花费 所以状态的转移是由前往后递推的,假如当前状态是cu…
Alice's mooncake shop Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4122 Description The Mid-Autumn Festival, also known as the Moon Festival or Zhongqiu Festival is a popular harvest festival celebrated by Ch…
点我看题目 题意 : 中文题不详述. 思路 :类似于01背包的DP,就是放与不放的问题,不过这个要求概率,至少得到一份offer的反面就是一份也得不到,所以先求一份也得不到的概率,用1减掉就可以得到所求. //HDU 1203 #include <stdio.h> #include <iostream> using namespace std ; struct node { int a ; double b ; }p[] ; ] ; int main() { int n,m ; w…
点我看题目 题意 :两条平行线上分别有两种城市的生存,一条线上是贫穷城市,他们每一座城市都刚好只缺乏一种物资,而另一条线上是富有城市,他们每一座城市刚好只富有一种物资,所以要从富有城市出口到贫穷城市,所以要修路,但是不能从富有的修到富有的也不能从贫穷的修到贫穷的,只能从富有的修到贫穷的,但是不允许修交叉路,所以问你最多能修多少条路. 题意 :这个题一开始我瞅了好久都没觉得是DP,后来二师兄给讲了一下才恍然大悟.其实就是用到了DP中的那个最长上升子序列,把题中贫穷城市的坐标当成数组的下标,跟其相连…
The Ghost Blows Light Problem Description My name is Hu Bayi, robing an ancient tomb in Tibet. The tomb consists of N rooms (numbered from 1 to N) which are connected by some roads (pass each road should cost some time). There is exactly one route be…
http://poj.org/problem?id=3691 http://acm.hdu.edu.cn/showproblem.php?pid=2457 DNA repair Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 5690   Accepted: 2669 Description Biologists finally invent techniques of repairing DNA that contain…
http://acm.hdu.edu.cn/showproblem.php? pid=1224 基础的求最长路以及记录路径. 感觉dijstra不及spfa好用,wa了两次. #include <stdio.h> #include <algorithm> #include <set> #include <map> #include <vector> #include <math.h> #include <string.h>…
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4616 这道题目数据可能比较弱,搜索都可以AC,但是不敢写,哎…… 搜索AC代码: #include <iostream> #include <cstdio> #include <cstring> #include <string> #include <cstdlib> #include <cmath> #include <vecto…