CF1794B Not Dividing题解】的更多相关文章

思路: 设dp[i]为覆盖i所用的最小数量,那么dp[i] = min(dp[k] + 1),其中i - 2b <= k <= i -2a,所以可以手动开一个单调递增的队列,队首元素就是k. 初始状态为dp[0] = 0,注意喷水覆盖的范围是偶数且不重叠,所以插入队列的必是偶数.有牛的地方不能作为边界,所以这些地方都要排除,可以用vis标记或者其他方法. 代码: #include<map> #include<ctime> #include<cmath> #i…
1.题目描述 2.题目分析 简单题目,只要挨个判断该数是不是满足条件即可. 3.代码 vector<int> selfDividingNumbers(int left, int right) { vector<int> ans; for(int i = left; i <= right; i++) { if( isDividingNumber(i) ) ans.push_back(i); } return ans; } bool isDividingNumber( int n…
Problem Description Marsha and Bill own a collection of marbles. They want to split the collection among themselves so that both receive an equal share of the marbles. This would be easy if all the marbles had the same value, because then they could…
题目意思 有六种不同的石子,权值为\(1\)~\(6\),给出六种石子的数量,求能否将石子分成权值相等的两份. 解析 这题可以直接用多重背包写, 因为仔细想想, 能够平均分成两份, 也就是能将一部分石子拼成总权值的二分之一. 那么,直接用可行性DP写就行了. (对于可行性DP请自行上百度吧qwq(因为这又是另一个故事了) 上代码吧: #include <iostream> #include <cstdio> #include <cstring> using namesp…
B. Fox Dividing Cheese time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Two little greedy bears have found two pieces of cheese in the forest of weight a and b grams, correspondingly. The be…
D. Dividing Kingdom II   Long time ago, there was a great kingdom and it was being ruled by The Great Arya and Pari The Great. These two had some problems about the numbers they like, so they decided to divide the great kingdom between themselves. Th…
续.....TAT这回不到50题编辑器就崩了.. 这里塞40道吧= = bzoj 1585: [Usaco2009 Mar]Earthquake Damage 2 地震伤害 比较经典的最小割?..然而一开始还是不会QAQ 和地震伤害1的区别在于这题求的是最少的损坏牧场数目.把牧场拆点,因为要让1和被报告的点不联通,把1归到S集,被报告的点归到T集,就变成求最小割了. 具体建图: 假设点拆成x和x’,x和x‘间连边(就是等下要割的).被报告的点和1点:容量无穷大(不能割):其他点容量为1. 原图中…
[CF687D]Dividing Kingdom II 题意:给你一张n个点m条边的无向图,边有边权$w_i$.有q个询问,每次给出l r,问你:如果只保留编号在[l,r]中的边,你需要将所有点分成两个集合,使得这个划分的代价最小,问最小代价是什么.一个划分的代价是指,对于所有两端点在同一集合中的边,这些边的边权最大值.如果没有端点在同一集合中的边,则输出-1. $n,q\le 1000,m\le \frac {n(n-1)} 2,w_i\le 10^9$ 题解:先考虑暴力的做法,我们将所有边按…
突然很想刷刷题,LeetCode是一个不错的选择,忽略了输入输出,更好的突出了算法,省去了不少时间. dalao们发现了任何错误,或是代码无法通过,或是有更好的解法,或是有任何疑问和建议的话,可以在对应的随笔下面评论区留言,我会及时处理,在此谢过了. 过程或许会很漫长,也很痛苦,慢慢来吧. 编号 题名 过题率 难度 1 Two Sum 0.376 Easy 2 Add Two Numbers 0.285 Medium 3 Longest Substring Without Repeating C…
D. Dividing Kingdom II 题目连接: http://www.codeforces.com/contest/687/problem/D Description Long time ago, there was a great kingdom and it was being ruled by The Great Arya and Pari The Great. These two had some problems about the numbers they like, so…