
思维
李自行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 · 250 阅读 · 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 · 162 阅读 · 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 · 199 阅读 · 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 · 94 阅读 · 0 评论 -
HDU - 6266 Hakase and Nano【思维】
题目Problem C. Hakase and NanoHakase and Nano are playing an ancient pebble game (pebble is a kind of rock). There are n packsof 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 · 165 阅读 · 0 评论 -
HDU - 6264 Super-palindrome 【思维】
题目You are given a string that is consisted of lowercase English alphabet. You are supposed to change itinto a super-palindrome string in minimum steps. You can change one character in string to anotherletter per step.A string is called a super-palindro原创 2020-10-08 21:04:26 · 89 阅读 · 0 评论 -
Codeforces Round #672 (Div. 2)C1. Pokémon Army (easy version)【思维+贪心】
题目传送门输入33 01 3 22 01 27 01 2 5 4 3 6 7输出329题意:t组测试样例,下面两个数n,m;在下面是n个数,从中按顺序选不超过n个数满足这几个数的先加后减运算值最大.思路:我们肯定要加上最大的减去最小的,即为加上一段上升序列中最大值,下降序列中最小值,最后一步操作一定应该为加法,这样保证.值最大AC code#include<iostream>#include<algorithm>#include&l原创 2020-10-05 21:32:43 · 232 阅读 · 0 评论 -
Gym - 102394IInteresting Permutation【特判+思维】
题目传送门Input330 2 230 1 230 2 3Output240题意: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 · 272 阅读 · 0 评论 -
Gym - 101875FNumber Preference【思维】
题目传送门Input31 3 1 2 32 1 11 3 1 2 4Output1Input51 3 1 2 31 3 1 2 41 3 1 2 51 3 1 2 72 1 8Output2Input21 2 10 112 2 10 11Output0题意:给出一个数n,下面是n个人,每个人的开头有一个数1或2后面跟着一个数m,如果是一的话表示后面是这个人喜欢的m个数,否则为厌恶的m个数.问:有多少的个数是所有人都喜欢的,输出这个数.思路:我们可原创 2020-10-02 21:36:42 · 166 阅读 · 0 评论 -
Gym - 101875DCheckerboard【思维】
题目传送门Input5 1 1 2 3Output2Input500 -100 -100 100 100Output51题意:给出一个n个面的骰子后面为起点和终点的坐标,骰子上面1~n,掷骰子一次,问有多少个数可以使从起点到终点(可以重复到一个点)思路:如果两点间的距离大于n就不可能到达终点,否则的话一定有一个从起点到终点的最小步数,再加上2的倍数的步数一定满足.#include<iostream>#include<algorithm>#in原创 2020-10-02 21:22:11 · 139 阅读 · 0 评论 -
Gym - 101911K Medians and Partition【判断分段】
题目传送门Input5 210 3 2 3 2Output5Input5 310 3 2 3 2Output1Input5 410 3 2 3 2Output0题意:给出两个数n,m,下面是n个数,从小到大排序后做多能分成几段使每段的中位数都大于等于m,注意长度为偶数时取中间最小的一个.思路,首先一个一个判断如果这个数直接大于m,因为是排好序的那么他后面的数一定也大于等于m,每个数分一段跳出来即可,否则这段往后延伸直到中位数大于等于m.AC code#i原创 2020-10-02 10:00:46 · 212 阅读 · 0 评论 -
Gym - 101911C - Bacteria【优先队列+思维】
题目传送门输入21 4输出2输入33 6 9输出-1输入71000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000输出1题意:先给出一个数n代表细菌的数量,下面给n个数ai代表细菌的体积,每两个相同体积的细菌可以合并,没有相同体积的细菌可以购买.问:至少购买几个细菌使细菌可以合并为一个,不能合并为一个的话输出-1思路:使用优先队列先取出一个数判断和队顶元素是否相同,原创 2020-10-01 10:59:20 · 128 阅读 · 0 评论 -
Gym - 101911A - Coffee Break【优先队列+map】
题目传送门输入4 5 33 5 1 2输出33 1 1 2输入10 10 110 5 7 4 6 3 2 1 9 8输出22 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 · 125 阅读 · 0 评论 -
Codeforces Round #670 (Div. 2)B. Maximum Product【思维】
传送门题目输入45-1 -2 -3 -4 -56-1 -2 -3 1 2 -16-1 0 0 0 -1 -16-9 -7 -5 -3 -2 1输出:-120120945题意:给出n个数求5个数的最大乘积思路:除了最大的5个最大数相乘外要考虑负数的情况,每次取两个最小数因为他们可能都为负数,乘积为正AC code#include<iostream>#include<algorithm>#include<cstring>原创 2020-09-24 21:54:05 · 160 阅读 · 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 · 148 阅读 · 0 评论 -
Codeforces Round #667 (Div. 3) D【思维+模拟】
传送门测试样例inputCopy52 11 1500 4217871987498122 10100000000000000001 1输出805002128012501878899999999999999999题意:给你两个数a,b,每次使a+1,问:至少多少次使a每位数字的和小于等于b思路:模拟一下数字的增加和每位数字的和的变化我们可以发现当最后一位数字增加时数字总和也在增加当最后一位数字变成零时,往前进一这时数字的总合可能变小,每位数字都是这样.所以我们只需要从原创 2020-09-22 14:46:57 · 124 阅读 · 0 评论 -
HDU - 6489The puzzle【思维题】
//题意:有n个数字任意排列,每次交换两个数,问:最少交换多少次可以让n个数按顺序排列//思路:从第一个位置开始判断数字是否和他的下标相同相同的话不用不用管,//不同的话开标记数组当这个数字没有被寻找过的话//寻找这个数字对应位置的数//直到找到数字和下标相等或者这个数字已经被找过#include<iostream>#include<algorithm>#include<cstring>#include<map>#include<s.原创 2020-09-19 14:00:42 · 258 阅读 · 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 · 150 阅读 · 0 评论