Aizu 2305 Beautiful Currency DP】的更多相关文章

Beautiful Currency Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=93265#problem/F Description KM country has N kinds of coins and each coin has its value a_i. The king of the country, Kita_masa, thou…
F. Beautiful Currency Time Limit: 5000ms Case Time Limit: 5000ms Memory Limit: 65536KB 64-bit integer IO format: %lld      Java class name: Main cid=6641#" class="submitprob button ui-button ui-widget ui-state-default ui-corner-all ui-button-tex…
题 题意 给你n个货币价格,然后通过调整一些货币的大小,使得所有比自己小的货币都是该货币的约数,调整前第 i 货币为a,调整后为b 那么变化率为 ri=|a-b|/a ,总变化率为max(ri).求最小的总变化率. 分析 DP 状态转移方程 dp[i][k]=min(max(dp[i-1][j], |k-a[i]|/a[i])); dp[i][k]表示前i个货币调整后,第i个货币为k时,最大的变化率是多少. 因为每个货币都是前面货币的倍数,所以只要它是前一个货币的倍数即可. 我们枚举前一个货币的…
题意 定义一个\(n*n\)的矩阵是\(beautiful\)的,需要满足以下三个条件: 1.每一行是一个排列. 2.上下相邻的两个元素的值不同. 再定义两个矩阵的字典序大的矩阵大(从左往右从上到下一个一个比较). 给出一个\(beautiful\)的\(n*n\)的矩阵,求有多少个矩阵小于这个矩阵. Solution 逐行计算. \(ans=\)每行字典序比这行小的排列且与上一行相邻的两个元素值不同的排列个数*\(n\)个元素错排的方案数\(^{n-i}\) 第一行的方案数随便算,我就不说了.…
Problem D. What a Beautiful Lake Description Weiming Lake, also named "Un-named Lake", is the most famous scenic spot in Peking University. It is located in the north of the campus and is surrounded by walking paths, small gardens, and old red b…
时间限制:0.25s 空间限制:4M 题意: 有n个人,每个人有两个能力值,只有一个人的两个能力都小于另一个的能力值,这两个人才能共存,求能同时共存的最大人数. Solution: 显然这是一个两个关键字的最长上升序列. 先按照第一种能力值为第一关键字从小到大,第二能力值为第二关键字从大到小排序(为什么?) 然后就是直接用O(nlogn)的DP就好了 (排序的方法是根据O(nlogn)DP算法中所用到的辅助数组的性质...如果对这个算法理解足够的话应该比较容易想到) code(要用C++提交)…
题意 给出一个长度为\(n\)的数列和数字\(x\),经过最多一次操作将数列的一个子段的每个元素变为\(a[i]*x\),使该数列的最大子段和最大 分析 将这个数列分为3段考虑,第一段和第三段是未修改的,第二段是修改的子段 设\(dp[i][j]\)为第\(i\)个数字为第\(j+1\)段的最大子段和 三种转移方程 第一段:\(dp[i][0]=max(a[i],dp[i-1][0]+a[i])\) 第二段:\(dp[i][1]=max(a[i]*x,dp[i-1][0]+a[i]*x,dp[i…
https://codeforces.com/contest/1155/problem/D 这个题目还是不会写,挺难的,最后还是lj大佬教我的. 这个题目就是要分成三段来考虑, 第一段就是不进行乘,就是直接求这一个区间的最大的一段区间的最大值. 第二段就是后面有一部分进行乘法,前面有一部不进行乘法.这个也同样求一个区间的最大值. 第三段就是前面有一部分和后面有一部分不进行乘法,中间有一部分进行乘法,同样求这个区间的最大值. #include<cstdio> #include<iostre…
题目来源:http://codeforces.com/problemset/problem/55/D Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer number is beautiful if and only if it is divisible by each of its nonzero digits. We will not argue wit…
D. Beautiful Pairs of Numbers time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output The sequence of integer pairs (a1, b1), (a2, b2), ..., (ak, bk) is beautiful, if the following statements are…