滚动数组优化dp CF570E Pig and Palindromes 原题链接 题意: 给定一个n*m(n,m ? 500)的字符矩阵,从(1,1)走到(n,m),每次只能向右和向下走,那么有多少种走法可以组成一个回文串。 思路: 由于形成的是回文串,我们可以假设有两个点,点A从(1,1)出发,点 ...
分类:
编程语言 时间:
2021-05-04 15:23:04
阅读次数:
0
题目链接: "HDU 5119" Problem Description Matt has N friends. They are playing a game together. Each of Matt’s friends has a magic number. In the game, Mat ...
分类:
移动开发 时间:
2019-09-14 00:48:37
阅读次数:
116
"HDU 6578 Blank " 题意 给你$\{0,1,2, 3\}$四个数,分别填入长度为$n$的数列中,有$m$个限制条件,$l_{i}, r_{i}, x_{i}$表示在$[l_{i}, r_{i}]$区间内,只能有$x_{i}$个不同的数。问一共有多少总方案。 思路 首先, 我们可以用$ ...
分类:
编程语言 时间:
2019-07-31 09:13:18
阅读次数:
168
题意 给你一个n和k,问n经过k次操作之后留下的n的期望,每次操作n随机变成一个n的因数 题解 概率dp计算出每个素因子留下的概率,乘以这个素因子的值就是这个素因子的贡献期望 定义$dp[i][j]$为第i次操作后剩下j个素因子的概率, 概率dp顺着推 $dp[i][j] dp[i+1][k](k ...
分类:
编程语言 时间:
2019-05-03 19:59:03
阅读次数:
161
传送门:点我 978. Longest Turbulent Subarray 978. Longest Turbulent Subarray A subarray A[i], A[i+1], ..., A[j] of A is said to be turbulent if and only if: ...
分类:
编程语言 时间:
2019-01-23 23:25:39
阅读次数:
317
题面 "传送门" 分析 考虑DP 设$dp[i][j]$表示前i个数选出的序列长度为j的方案数 状态转移方程为: $$ dp[i][j]= \begin{cases}dp\left[ i 1\right] \left[ j 1\right] +dp\left[ i 1\right] \left[ j ...
分类:
编程语言 时间:
2018-11-24 22:28:42
阅读次数:
321
Charm Bracelet Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 47440 Accepted: 20178 Description Bessie has gone to the mall's jewelry stor ...
分类:
编程语言 时间:
2018-08-24 19:26:49
阅读次数:
208
#include<bits/stdc++.h> using namespace std; int dp[1005];//滚动数组的写法,省下空间省不去时间 int weight[1005]; int value[1005]; int main() { int n,m; cin>>m>>n; mems ...
分类:
其他好文 时间:
2018-03-06 21:40:45
阅读次数:
155
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1231 题意: 给你n个数字s[i],问你有多少个排列,使得任意相邻两数字之差的绝对值大于m。 题解: 表示状态: dp[i][j][state] = arrangements i:考虑到第i ...
分类:
编程语言 时间:
2017-10-03 23:18:17
阅读次数:
308
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=1024 Max Sum Plus Plus Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/O ...
分类:
编程语言 时间:
2017-10-02 17:50:41
阅读次数:
260