动态规划
这波lucio来全学了
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Codeforces #319(Div.2) B. Modulo Sum (动态规划)
题意:两个数n和m,还有a1-an的n个数,判断是否存在该数列的一个子序列,使得子序列元素的和可以被m整除。看了下官方题解:分两种情况:n>m 和 n<=m。如果n>m, 可以判断输出一定为“Yes”。求出前 i 个数的和 S1-Sn,有鸽巢原理,可以知道至少有两个数列和对m取模的结果相等,假设为Sl%m=Sr%m,则可以知道(Sl-Sr)%m==0,于是 [ l+1,r ]就是所求的子序列。如果n<=m, 用动态规划解决,O(m^2)。dp[i][r]表示到了第i个数,前面子序列的和对m取模是否能原创 2015-09-12 10:55:08 · 1153 阅读 · 0 评论 -
URAL - 1826 Minefield
MinefieldTime Limit: 500MS Memory Limit: 65536KB 64bit IO Format: %I64d & %I64uSubmit StatusDescriptionTo fulfill an assignment, a reconnaissance group of n peo原创 2015-04-21 02:36:55 · 1104 阅读 · 0 评论 -
UVALive - 6801 Sequence
题目链接https://icpcarchive.ecs.baylor.edu/external/68/6801.pdf借下队友的代码。#include#include#includeunsigned long long dp[1010][1010];bool flag[1010][1010];char a[1010];using namespace std;int mai原创 2015-04-24 01:45:37 · 1161 阅读 · 0 评论 -
POJ - 1163 The Triangle
The TriangleTime Limit: 1000MS Memory Limit: 10000KB 64bit IO Format: %I64d & %I64uSubmit StatusDescription73 88 1 02 7 4 44 5 2 6 5原创 2015-03-27 13:12:27 · 654 阅读 · 0 评论 -
POJ - 2479 Maximum sum
Maximum sumTime Limit: 1000MS Memory Limit: 65536KB 64bit IO Format: %I64d & %I64uSubmit StatusDescriptionGiven a set of n integers: A={a1, a2,..., an}, we defi原创 2015-03-28 14:18:41 · 677 阅读 · 0 评论 -
ZOJ - 1733 Common Subsequence
Common SubsequenceTime Limit: 2000MS Memory Limit: 65536KB 64bit IO Format: %lld & %lluSubmit StatusDescriptionA subsequence of a given sequence is the given sequ原创 2015-03-28 16:27:35 · 704 阅读 · 0 评论 -
POJ - 1159 Palindrome
PalindromeTime Limit: 3000MS Memory Limit: 65536KB 64bit IO Format: %I64d & %I64uSubmit StatusDescriptionA palindrome is a symmetrical string, that is, a string原创 2015-03-28 17:31:16 · 615 阅读 · 0 评论 -
CodeForces - 484D Kindergarten
KindergartenTime Limit: 2000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64uSubmit StatusDescriptionIn a kindergarten, the children are being divided into原创 2015-03-29 02:37:15 · 867 阅读 · 0 评论 -
POJ - 3624 Charm Bracelet
Charm BraceletTime Limit: 1000MS Memory Limit: 65536KB 64bit IO Format: %I64d & %I64uSubmit StatusDescriptionBessie has gone to the mall's jewelry store and s原创 2015-03-29 02:56:07 · 723 阅读 · 0 评论 -
HDU - 1114 Piggy-Bank
Piggy-BankTime Limit: 1000MS Memory Limit: 32768KB 64bit IO Format: %I64d & %I64uSubmit StatusDescriptionBefore ACM can do anything, a budget must be prepared and原创 2015-03-29 03:01:23 · 726 阅读 · 0 评论 -
HDU - 3466 Proud Merchants
Proud MerchantsTime Limit: 1000MS Memory Limit: 65536KB 64bit IO Format: %I64d & %I64uSubmit StatusDescriptionRecently, iSea went to an ancient country. For such原创 2015-03-29 03:03:54 · 798 阅读 · 0 评论 -
Codeforces#321 (Div. 2) D. Kefa and Dishes(DP,掩码)
题意:Kefa 去吃东西,菜单上有n中菜可以选,每种菜分别会带给kefa ai的满足感,此外有k条规则,给出u,v,c,先吃u再吃v会得到c的满足感。kefa要吃m种菜,求得到满足感的最大值。思路:用一个二维的dp数组,第一个元素用掩码表示已经拿的菜,注意大小是2^18,第二个元素表示拿的最后一种菜,先置dp数组为-1,以此来消除掩码没有意义的空元素,可以知道,初始状态是第i种菜先拿的时候,值为ai,状态转移,后面的状态有原来dp[][j] ,或者是先拿一个i再拿j得到,为dp[]+c[j]+g[i][j原创 2015-09-23 22:57:11 · 1633 阅读 · 2 评论
分享