思维
李自行h
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Codeforces Round #656 (Div. 3)D. a-Good String【搜索】
题目 传送门 You are given a string s[1…n] consisting of lowercase Latin letters. It is guaranteed that n=2k for some integer k≥0. The string s[1…n] is called c-good if at least one of the following three conditions is satisfied: The length of s is 1, and it con原创 2020-10-20 21:21:08 · 284 阅读 · 0 评论 -
Codeforces Round #658 (Div. 1)A1. Prefix Flip (Easy Version)【思维】
题目 传送门 This is the easy version of the problem. The difference between the versions is the constraint on n and the required number of operations. You can make hacks only if all versions of the problem are solved. There are two binary strings a and b of len原创 2020-10-19 21:16:16 · 196 阅读 · 0 评论 -
Educational Codeforces Round 91 (Rated for Div. 2)C. Create The Teams【贪心】
题目 传送门 There are n programmers that you want to split into several non-empty teams. The skill of the i-th programmer is ai. You want to assemble the maximum number of teams from them. There is a restriction for each team: the number of programmers in the t原创 2020-10-19 14:22:40 · 227 阅读 · 0 评论 -
Educational Codeforces Round 94 (Rated for Div. 2)C. Binary String Reconstruction【思维】
题目 传送门 Consider the following process. You have a binary string (a string where each character is either 0 or 1) w of length n and an integer x. You build a new binary string s consisting of n characters. The i-th character of s is chosen as follows: if th原创 2020-10-17 14:50:35 · 122 阅读 · 0 评论 -
HDU - 6266 Hakase and Nano【思维】
题目 Problem C. Hakase and Nano Hakase and Nano are playing an ancient pebble game (pebble is a kind of rock). There are n packs of pebbles, and the i-th pack contains ai pebbles. They take turns to pick up pebbles. In each turn, they can choose a pack arbit原创 2020-10-09 09:48:54 · 197 阅读 · 0 评论 -
HDU - 6264 Super-palindrome 【思维】
题目 You are given a string that is consisted of lowercase English alphabet. You are supposed to change it into a super-palindrome string in minimum steps. You can change one character in string to another letter per step. A string is called a super-palindro原创 2020-10-08 21:04:26 · 121 阅读 · 0 评论 -
Codeforces Round #672 (Div. 2)C1. Pokémon Army (easy version)【思维+贪心】
题目 传送门 输入 3 3 0 1 3 2 2 0 1 2 7 0 1 2 5 4 3 6 7 输出 3 2 9 题意:t组测试样例,下面两个数n,m;在下面是n个数,从中按顺序选不超过n个数满足这几个数的先加后减运算值最大. 思路:我们肯定要加上最大的减去最小的,即为加上一段上升序列中最大值,下降序列中最小值,最后一步操作一定应该为加法,这样保证.值最大 AC code #include<iostream> #include<algorithm> #include&l原创 2020-10-05 21:32:43 · 256 阅读 · 0 评论 -
Gym - 102394IInteresting Permutation【特判+思维】
题目 传送门 Input 3 3 0 2 2 3 0 1 2 3 0 2 3 Output 2 4 0 题意:t组测试样例,开头一个n,下面是n个数,分别为前i个数的最大值和最小值之差,问:1~n有几种排列方法满足条件 思路:首先特别判定一下a[0]应该等于零,a[i]>=a[i-1],a[i]<n;满足这三个前提条件后有两种情况: 1:a[i]>a[i-1]此时前i个数的最大值或最小值更新,总数乘以2,最大值更新他们中间数(最大值和最小值中间还未用到的数)的总数增加,计算他们原创 2020-10-03 19:29:27 · 298 阅读 · 0 评论 -
Gym - 101875FNumber Preference【思维】
题目 传送门 Input 3 1 3 1 2 3 2 1 1 1 3 1 2 4 Output 1 Input 5 1 3 1 2 3 1 3 1 2 4 1 3 1 2 5 1 3 1 2 7 2 1 8 Output 2 Input 2 1 2 10 11 2 2 10 11 Output 0 题意:给出一个数n,下面是n个人,每个人的开头有一个数1或2后面跟着一个数m,如果是一的话表示后面是这个人喜欢的m个数,否则为厌恶的m个数.问:有多少的个数是所有人都喜欢的,输出这个数. 思路:我们可原创 2020-10-02 21:36:42 · 233 阅读 · 0 评论 -
Gym - 101875DCheckerboard【思维】
题目 传送门 Input 5 1 1 2 3 Output 2 Input 500 -100 -100 100 100 Output 51 题意:给出一个n个面的骰子后面为起点和终点的坐标,骰子上面1~n,掷骰子一次,问有多少个数可以使从起点到终点(可以重复到一个点) 思路:如果两点间的距离大于n就不可能到达终点,否则的话一定有一个从起点到终点的最小步数,再加上2的倍数的步数一定满足. #include<iostream> #include<algorithm> #in原创 2020-10-02 21:22:11 · 161 阅读 · 0 评论 -
Gym - 101911K Medians and Partition【判断分段】
题目 传送门 Input 5 2 10 3 2 3 2 Output 5 Input 5 3 10 3 2 3 2 Output 1 Input 5 4 10 3 2 3 2 Output 0 题意:给出两个数n,m,下面是n个数,从小到大排序后做多能分成几段使每段的中位数都大于等于m,注意长度为偶数时取中间最小的一个. 思路,首先一个一个判断如果这个数直接大于m,因为是排好序的那么他后面的数一定也大于等于m,每个数分一段跳出来即可,否则这段往后延伸直到中位数大于等于m. AC code #i原创 2020-10-02 10:00:46 · 242 阅读 · 0 评论 -
Gym - 101911C - Bacteria【优先队列+思维】
题目 传送门 输入 2 1 4 输出 2 输入 3 3 6 9 输出 -1 输入 7 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 输出 1 题意:先给出一个数n代表细菌的数量,下面给n个数ai代表细菌的体积,每两个相同体积的细菌可以合并,没有相同体积的细菌可以购买.问:至少购买几个细菌使细菌可以合并为一个,不能合并为一个的话输出-1 思路:使用优先队列先取出一个数判断和队顶元素是否相同,原创 2020-10-01 10:59:20 · 148 阅读 · 0 评论 -
Gym - 101911A - Coffee Break【优先队列+map】
题目 传送门 输入 4 5 3 3 5 1 2 输出 3 3 1 1 2 输入 10 10 1 10 5 7 4 6 3 2 1 9 8 输出 2 2 1 1 2 2 1 2 1 1 2 题意:先给出三个数,n,m,d,下面是n个数表示想在ai时刻休息,每天工作m分钟,每次休息的间隔不能小于d,问:至少要花费多少天才能把想休息的时刻休息完.(ai不相同) 思路:优先队列+map,如果队顶元素和ai间隔大于d,就说明他们可以在同一天,否则往后推天数 AC code #include<ios原创 2020-10-01 10:42:18 · 158 阅读 · 0 评论 -
Codeforces Round #670 (Div. 2)B. Maximum Product【思维】
传送门 题目 输入 4 5 -1 -2 -3 -4 -5 6 -1 -2 -3 1 2 -1 6 -1 0 0 0 -1 -1 6 -9 -7 -5 -3 -2 1 输出: -120 12 0 945 题意:给出n个数求5个数的最大乘积 思路:除了最大的5个最大数相乘外要考虑负数的情况,每次取两个最小数因为他们可能都为负数,乘积为正 AC code #include<iostream> #include<algorithm> #include<cstring>原创 2020-09-24 21:54:05 · 183 阅读 · 0 评论 -
Codeforces Round #671 (Div. 2)C. Killjoy【思维】
传送门 读了这个题好长时间题意比较难懂 题意:给你两个数n,x,下面是n个数,每次比赛时你可以改变任意多个数的大小但是所有数的变化之和必须为零,在每次比赛前后大小等于x的数都被感染.问:至少需要多少场比赛能把他们全都感染 思路:比赛前可以分为三种情况 1 有n个数和x相等,这样的话比赛前就可以把他们全都感染 2 有1~n-1个数与x相等(已被感染),这样的话我们需要一场比赛把其他不等于x的数变为x,而相反值都加在已经感染的数字上,比赛后把没有感染的感染了就可以了. 3有0个数与x相等,如果n个数的和能原创 2020-09-24 14:35:00 · 175 阅读 · 0 评论 -
Codeforces Round #667 (Div. 3) D【思维+模拟】
传送门 测试样例 inputCopy 5 2 1 1 1 500 4 217871987498122 10 100000000000000001 1 输出 8 0 500 2128012501878 899999999999999999 题意:给你两个数a,b,每次使a+1,问:至少多少次使a每位数字的和小于等于b 思路:模拟一下数字的增加和每位数字的和的变化我们可以发现当最后一位数字增加时数字总和也在增加当最后一位数字变成零时,往前进一这时数字的总合可能变小,每位数字都是这样.所以我们只需要从原创 2020-09-22 14:46:57 · 160 阅读 · 0 评论 -
HDU - 6489The puzzle【思维题】
//题意:有n个数字任意排列,每次交换两个数,问:最少交换多少次可以让n个数按顺序排列 //思路:从第一个位置开始判断数字是否和他的下标相同相同的话不用不用管, //不同的话开标记数组当这个数字没有被寻找过的话 //寻找这个数字对应位置的数 //直到找到数字和下标相等或者这个数字已经被找过 #include<iostream> #include<algorithm> #include<cstring> #include<map> #include<s.原创 2020-09-19 14:00:42 · 292 阅读 · 0 评论 -
HDU - 6486【逆向思维】
//题意:给你n个数,每次让n-1个数减一,问:最少多少次可以让这几个数相等,不可以的话输出-1 //思路:逆向思维,n-1个数-1可以等价于另一个数加一,这样的话可以算出最小操作次数.然后还是按照减法来说 //每次的话一定会让最大的数减一,我们直接判断最大的数是否大于操作次数就可以了(a[i]>0)操作次数小于最大值 //输出操作数,否则输出-1; AC代码 #include<iostream> #include<algorithm> #include<cstrin.原创 2020-09-19 10:28:00 · 174 阅读 · 0 评论
分享