序列期望 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 247 Accepted Submission(s): 119 Problem Description “看似随机,实则早已注定”——光羽 度度熊有n个随机变量x1,x2,...,xnx1,x2,...,xn.给定区间[l1,r1],...,[ln,rn][l1,r1],..…
balls Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5570 Description There are n balls with m colors. The possibility of that the color of the i-th ball is color j is ai,jai,1+ai,2+...+ai,m. If the number of b…
poj 2096 题目:http://poj.org/problem?id=2096 f[ i ][ j ] 表示收集了 i 个 n 的那个. j 个 s 的那个的期望步数. #include<cstdio> #include<cstring> #include<algorithm> #define db double using namespace std; ; db n,s,f[N][N]; int main() { scanf("%lf%lf"…
Problem Description There are x cards on the desk, they are numbered from 1 to x. The score of the card which is numbered i(1<=i<=x) is i. Every round BieBie picks one card out of the x cards,then puts it back. He does the same operation for b round…
Problem Description Sakura has a very magical tool to paint walls. One day, kAc asked Sakura to paint a wall that looks like an M×N matrix. The wall has M×N squares in all. In the whole problem we denotes (x,y) to be the square at the x-th row, y-th…
序列变换 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 519 Accepted Submission(s): 245 Problem Description 我们有一个数列A1,A2...An,你如今要求改动数量最少的元素,使得这个数列严格递增.当中不管是改动前还是改动后,每一个元素都必须是整数. 请输出最少须要改动多少个元素…
When wake up, lxhgww find himself in a huge maze. The maze consisted by N rooms and tunnels connecting these rooms. Each pair of rooms is connected by one and only one path. Initially, lxhgww is in room 1. Each room has a dangerous trap. When lxhgww…
题目链接: 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…
最长上升子序列 nlogn;也是从别人的博客学来的 #include<iostream> #include<algorithm> #define maxn 100000+5 using namespace std; int n; int a[maxn]; int solve(int b[],int l) { int f[maxn];//f[i]表示子序列长度为i+1的序列中,末尾元素最小的元素的值 int k=0; f[k++]=b[0]; for(int i=1;i<l;i…
有 0到 n 个格子.掷骰子走路,求出到终点的数学期望,有飞行的路线. dp[i] 存储在i位置走到终点的期望. 转移方程dp[i]=(dp[i+1] ----> dp[i+6])/6+1; 有飞行路线则直接赋值 #include "stdio.h" #include "string.h" double dp[100010]; int hash[100010]; int main() { int n,m,x,y,i,j; while (scanf("…
题目链接:hdu 4521 本是 dp 的变形,却能用线段树,感觉好强大. 由于 n 有 10^5,用普通的 dp,算法时间复杂度为 O(n2),肯定会超时.所以用线段树进行优化.线段树维护的是区间内包含某点的最大满足条件的长度,叶子节点以该元素结尾,最长长度.至于相邻两项隔 d 个位置,求 dp[i] 时,我们只把 dp[i - d - 1] 更新至线段树中,然后在这颗线段树中找最大的个数. 具体来说,就是把序列 S 的值 Ai 作为线段树叶子下标,以 Ai 结尾的 LIS 长度(即经典算法里…
题目链接: 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…