题解 [HDU 6745] Dec (简单DP)】的更多相关文章

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4576 题意:给出1~n的环,m个操作,每次能顺时针或逆时针走w步,询问最后在l~r这段区间内概率.(1<=n<=200) ,(0<=m<=1,000,000),(1<=l<=r<=n).分析:每次从某一个数字到达另外数字的概率为0.5,按概率dp求出到达每个数字的概率,然后枚举从l到r的概率相加即可.dp[i][j]表示第i次操作落在数字j上的概率,但是不能直接开10…
题意: Problem Description 初始有 a, ba,b 两个正整数,每次可以从中选一个大于 1 的数减 1,最后两个都会减到 1,我们想知道在过程中两个数互质的次数最多是多少. Input 第一行一个正整数 test(1 \le test \le 1000000)test(1≤test≤1000000) 表示数据组数. 接下来 test 行,每行两个正整数 a, b(1 \le a, b \le 1000)a,b(1≤a,b≤1000). Output 对于每组数据,一行一个整数…
题意:给你一个序列,问相邻两数高度差绝对值小于等于H的子序列有多少个. dp[i]表示以i为结尾的子序列有多少,易知状态转移方程为:dp[i] = sum( dp[j] ) + 1;( abs( height[i] - height[j] ) <= H ) 由abs( height[i] - height[j] ) <= H 可得 height[i] - H <= height[j] <= height[i] + H 将序列中的数离散化,每个height对应一个id, 用树状数组求…
Problem Description Given a matrix with n rows and m columns ( n+m ,) and you want to go to the number at bottom-right corner (n,m). And you must go right or go down every steps. Let the numbers you go through become an array a1,a2,...,a2k. The cost…
Frog Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 712    Accepted Submission(s): 338 Problem Description A little frog named Fog is on his way home. The path's length is N (1 <= N <= 100),…
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 33384    Accepted Submission(s): 15093 Problem Description Nowadays, a kind of chess game called “Super Jumping!…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2571 简单dp, dp[n][m] +=(  dp[n-1][m],dp[n][m-1],d[i][k] ) k 为m的因子 PS:0边界要初始为负数(例如-123456789)越大越好 代码: #include <stdio.h> #include <string.h> int dp[25][1005]; #define max(x,y) x > y ? x : y int m…
这一次组织了一场\(dp\)的专项考试,出了好几道经典的简单\(dp\)套路题,特开一篇博客写一下题解. Tower(双向dp) Description 信大家都写过数字三角形问题,题目很简单求最大化一个三角形数塔从上往下走的路径和.走的规则是:(i,j)号点只能走向(i+1,j)或者(i+1,j+1).如下图是一个数塔,映射到该数塔上行走的规则为:从左上角的点开始,向下走或向右下走直到最底层结束. 1 3 8 2 5 0 1 4 3 8 1 4 2 5 0 路径最大和是1+8+5+4+4 =…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5375 题面: Gray code Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 626    Accepted Submission(s): 369 Problem Description The reflected binary cod…
题目 简单dp //简单的dp #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; ][];//dp[i][j] di i ceng di j ge zui da he ][]; int main() { int t; scanf("%d",&t); while(t--) { int n; scanf("%d",&…