problem 1033. Moving Stones Until Consecutive 参考 1. Leetcode_easy_1033. Moving Stones Until Consecutive; 完…
题目如下: Three stones are on a number line at positions a, b, and c. Each turn, you pick up a stone at an endpoint (ie., either the lowest or highest position stone), and move it to an unoccupied position between those endpoints.  Formally, let's say th…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 脑筋急转弯 日期 题目地址:https://leetcode.com/problems/moving-stones-until-consecutive/ 题目描述 Three stones are on a number line at positions a, b, and c. Each turn, you pick up a stone at…
[LeetCode]659. Split Array into Consecutive Subsequences 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/split-array-into-consecutive-subsequences/description/ 题目描述: You are g…
这是小川的第386次更新,第414篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第247题(顺位题号是1033).在a,b和c位置的数字线上有三块石头.每次,你在一个终点(即最低或最高位置的石头)上拾取一块石头,然后将它移动到这些终点之间的空置位置. 形式上,假设石头当前位于x,y,z位置,x <y <z.你在x位置或z位置拾取石头,然后将石头移动到整数位置k,x <k <z且k!= y. 当你不能做任何移动时,游戏结束.例如,当石头处于连续的位置时.…
[算法]网络流-最小费用最大流(费用流) [题解]与方格取数2类似 在S后添加辅助点S_,限流k 每条边不能重复走,限流1 #include<cstdio> #include<algorithm> #include<cstring> using namespace std; ,maxN=; ]; ,first[maxN],p[maxn][maxn*],q[],d[maxN],N,S,T,S_;//梯形输入,p的第二维翻倍 long long ans; bool vis[…
problem 771. Jewels and Stones solution1: class Solution { public: int numJewelsInStones(string J, string S) { ; unordered_set<char> js(J.begin(), J.end()); for(auto ch:S) { if(js.find(ch)!=js.end()) res++; } return res; } }; 参考 1. Leetcode_easy_771…
Three stones are on a number line at positions a, b, and c. Each turn, let's say the stones are currently at positions x, y, z with x < y < z.  You pick up the stone at either position x or position z, and move that stone to an integer position k, w…
初探数位dp 介绍了数位类统计的基础知识.以下列出其中的基础点: 基本问题 统计在区间[l, r]中满足条件的数的个数 思路 1. [l, r] 将问题转换为 在[0, r]中满足条件的个数 - 在[0, l)满足条件的个数 2. 求解 区间[0, n]满足条件的个数 性质:一个小于n的数m,一定是从高位到低位在某一位小于n的对应位的一个数   数值 百位 十位 个位   n   m 3 5 0<8 m 349 3 4<5 遍历所有小于n的数:从高位到低位枚举第一次小于n的数位,之后数位的值就…
http://wikioi.com/problem/1033/ 这题也是很水的费用流啊,同之前那题一样,拆点然后建边,容量为1,费用为点权.然后建个源连第一行每个点,容量为1,费用为0,然后最后一行每个点连汇,容量为1,费用为0. 最后再建个超级源连一条边到源,容量为k,费用为0.再建个超级汇,汇连边到它,容量为k,费用为0. 跑一次费用流即可. #include <cstdio> #include <cstring> #include <cmath> #include…