09 2017 档案

摘要:https://hihocoder.com/problemset/problem/1586 线段树操作,原来题并不难。。。。。 当时忽略了一个重要问题,就是ax*ay要最小时,x、y可以相等,那就简单了!结果显然是模最小的数的平方或者是个负数。 要求乘积最小只要求区间内最大值、最小值和绝对值小的数, 阅读全文
posted @ 2017-09-30 19:58 ╰追憶似水年華ぃ╮ 阅读(249) 评论(0) 推荐(0)
摘要:2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 M. Frequent Subsets Problem 题意:给定N和α还有M个U={1,2,3,...N}的子集,求子集X个数,X满足:X是U的子集且出现在M个子集中的次数>=α*M。 题解:因为N<=20,所以U的子集个数最大不过2^20。所 阅读全文
posted @ 2017-09-28 15:41 ╰追憶似水年華ぃ╮ 阅读(200) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=6201 n个城市都在卖一种书,该书的价格在i城市为cost[i],商人打算从某个城市出发到另一个城市结束,途中可以在任意城市买书或者卖书,但一次只能买一本和卖一本,一个城市到另一个城市需要花费。问商人最大收益是多少 阅读全文
posted @ 2017-09-23 10:44 ╰追憶似水年華ぃ╮ 阅读(191) 评论(0) 推荐(0)
摘要:poj 2342 给出每个顶点的happy值,还有若干组两个顶点L,K关系,表示K是L的上司。求当K、L不同时出现时获得的happy值的最大和。 设dp[u][0]表示不选u结点时获得的最大值,dp[u][1]表示选u结点时获得的最大值。则有: dp[u][0]+=max(dp[v][0],dp[v 阅读全文
posted @ 2017-09-23 10:42 ╰追憶似水年華ぃ╮ 阅读(187) 评论(0) 推荐(0)
摘要:快速幂模板: 例题:hdu 1097 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> using namespace std; typedef long long ll 阅读全文
posted @ 2017-09-22 21:41 ╰追憶似水年華ぃ╮ 阅读(232) 评论(0) 推荐(0)
摘要:Problem Description We define a sequence F:⋅ F0=0,F1=1;⋅ Fn=Fn−1+Fn−2 (n≥2).Give you an integer k, if a positive number n can be expressed byn=Fa1+Fa2 阅读全文
posted @ 2017-09-22 21:40 ╰追憶似水年華ぃ╮ 阅读(227) 评论(0) 推荐(0)
摘要:Bob has a not even coin(就是一个不均匀的硬币,朝上的概率不一定是1/2), every time he tosses the coin, the probability that the coin's front face up is q/p(q/p<=1/2). The q 阅读全文
posted @ 2017-09-17 09:37 ╰追憶似水年華ぃ╮ 阅读(627) 评论(3) 推荐(0)
摘要:限制:1000ms 32768K Define the function S(x) for xx is a positive integer. S(x) equals to the sum of all digit of the decimal expression of x. Please fin 阅读全文
posted @ 2017-09-17 08:24 ╰追憶似水年華ぃ╮ 阅读(747) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1561 很容易想到如果是要攻克v城需要先攻克u城的话,可以建u到v的边。但是如果能够直接攻克u城呢?无边可建,这样就无法形成一棵树。因此虚拟出一个0结点去连接可直接攻克的城。这样只需多打一次0城即可。定义状态dp[ 阅读全文
posted @ 2017-09-16 09:37 ╰追憶似水年華ぃ╮ 阅读(209) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1054 给定一棵树,点能看住与其相连的边,问最少需要选定多少个点看住所有的边。 定义dp[maxn][2],dp[][0]表示不选当前顶点所获得的价值,dp[][1]表示选当前顶点所获得的价值。则: dp[u][0 阅读全文
posted @ 2017-09-16 09:29 ╰追憶似水年華ぃ╮ 阅读(198) 评论(0) 推荐(0)
摘要:hdu 6197 题意:给定一个数组,问删掉k个字符后数组是否能不减或者不增,满足要求则是magic array,否则不是。 题解:队友想的思路,感觉非常棒!既然删掉k个后不增或者不减,那么就先求数组的最长不下降子序列的长度l1和最长不上升子序列的长度l2,若l1>=n-k||l2>=n-k,则满足 阅读全文
posted @ 2017-09-13 17:09 ╰追憶似水年華ぃ╮ 阅读(181) 评论(0) 推荐(0)
摘要:2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛 H Skiing In this winter holiday, Bob has a plan for skiing at the mountain resort. This ski resort has MM different ski p 阅读全文
posted @ 2017-09-13 16:42 ╰追憶似水年華ぃ╮ 阅读(295) 评论(0) 推荐(0)
摘要:参考博客(感谢博主):http://blog.csdn.net/yo_bc/article/details/77917288 题意: 给定一个有向无环图,求该图的最长路。 思路: 由于是有向无环图,所以最长路肯定是一个入度为0到出度为0的路径,拓扑序在确定当前点之前能够考虑到所有到它的情况,所以最后 阅读全文
posted @ 2017-09-10 10:33 ╰追憶似水年華ぃ╮ 阅读(325) 评论(0) 推荐(0)
摘要:三角形数:an=n*(n+1)/2; 完全平方数:bn=c^2; 既是三角形数又是完全平方数:An=6*A(n-1)-A(n-2)+2; A[23]={ 0, 1, 8, 49, 288, 1681, 9800, 57121, 332928, 1940449, 11309768, 65918161, 阅读全文
posted @ 2017-09-10 09:02 ╰追憶似水年華ぃ╮ 阅读(667) 评论(0) 推荐(0)
摘要:HDU 2089 求给定区间内不含62和4的数的个数。 数位dp入门。从这里我清楚了一些数位dp的用法。比如limit是判断是否达到上界,而且需要判断(!limit).。比如若题目要求不含11的个数,举例来说:区间在[1,215],当百位开始枚举为0时,十位枚举1,个位可以取0,2~9,即dp[0] 阅读全文
posted @ 2017-09-09 10:07 ╰追憶似水年華ぃ╮ 阅读(200) 评论(0) 推荐(0)
摘要:AtCoder Regular Contest 082 D Derangement 与下标相同与下个交换就好了。。。。 Define a sequence of ’o’ and ’x’ of length N as follows: if pi ̸= i, the i-th symbol is ’o’ 阅读全文
posted @ 2017-09-02 22:03 ╰追憶似水年華ぃ╮ 阅读(168) 评论(0) 推荐(0)