题目
weixin_45817187
这个作者很懒,什么都没留下…
展开
-
Even-Odd Game
Even-Odd Game Codeforces-1472D2021.05.02 训练题G题目大意: Alice和Bob玩取数字游戏,Alice取得偶数就加上对应的分值,取得奇数不得分,Bob取得奇数就加上对应的分数,取偶数不得分,Alice先手取数字,问最终谁的得分高,平局输出 " Tie "**思路:**双栈或双数组,队列+贪心,将奇数排序放到一个数组中,偶数排序放到一个数组中,轮到谁,看奇数最大值和偶数最大值谁大取谁就可以了,注意奇数数组取完或者偶数数组取完的情况题目:During thei原创 2021-05-04 16:57:27 · 135 阅读 · 0 评论 -
Strange List
Strange List Codeforces-1417B**题目大意:**给定一个有n个数的数组,给定一个整数x,若第 i 处元素额能够整除 x ,则将整除过后的数复制 x 个放到数组尾部,i++,否则,停止操作,求最终数组的和是多少**思路:**重复从数组头部向尾部进行遍历,直到 arr[i] 不能整除x break题目:You have given an array a of length n and an integer x to a brand new robot. What the ro原创 2021-05-04 16:50:15 · 62 阅读 · 0 评论 -
New Colony
New Colony Codeforces-1481B2021.05.02 训练题E**题目大意:**有n座山,每座山的高度为hi,每次从第一座山开始扔石头,若石头所在的山的高度 hi >= h(i+1) 则石头会滚向下一座山,否则就会停留在这座山,这座山的高度自增1,求最后一块石头停留在第几座山,若滚过所有的山,则输出-1.**思路:**暴力遍历即可题目:After reaching your destination, you want to build a new colony on t原创 2021-05-04 16:09:20 · 55 阅读 · 0 评论 -
Add and Divide
Add and Divide Codeforces-1485A2021.05.02 训练题D**题目大意:**有两个正整数 a , b ,每次可进行两个操作,1.a/=b,2.b++ ,求需要最少多少步能让a==0**思路:**由于两次a/b和a/(b+1)的效果是一样的,故只需考虑a除以那个数能够保证除的次数最少即可,可以从2开始循环遍历,暴力求解题目You have two positive integers a and b.You can perform two kinds of ope原创 2021-05-04 15:45:50 · 122 阅读 · 0 评论 -
Balanced Remainders
Balanced Remainders Codeforces-1490B2021.05.02 训练题C**题目大意:**给你一组数据,让每个数对3取余,然后问最少多少步,能让三取余后的数,余数为0、余数为1、余数为2 的数字个数相同(0->1 是1步,0->2是2步)**思路:**由于0–>2是两步,与0–>1 + 1–>2是相同的,所以所有步骤都可以给相邻的数字,而不用考虑跨位给。直接暴力遍历,直到所有数字都相等题目:You are given a number n原创 2021-05-04 15:24:10 · 63 阅读 · 0 评论 -
ABC String
ABC String Codeforces-1494A2021.05.02 训练题B**题目大意:**给定一个字符串,该字符串由 ’ A ‘,’ B ',‘ C '三种字符组成,将这些字符替换成 ’ ( ’ 或者 ’ ) ’ 是否能得到标准的串(即 左右括号互相照应,有整数对括号组)**思路:**将第一个字符代表的字母替换成 ’ ( ’ ,将最后一个字符代表的字母替换成 ’ ) ',若第一个字符等于最后一个字符,一定不满足题意,若不相等,则将剩下的一个字母分别替换成 ’ ( ’ 和 ’ ) ’ 分别验原创 2021-05-04 15:15:31 · 86 阅读 · 0 评论 -
Napoleon Cake
Napoleon Cake Codeforces-1501B2021.05.02 训练题A**题目大意:**有n层蛋糕,每层蛋糕铺有奶油,奶油可以向下浸透arr[i]层蛋糕,问最终有多少层蛋糕被浸透**做题思路:**从后往前遍历arr数组,用一个变量temp记录当前状态下还能浸透多少层,用一个标记数组存下该层蛋糕是否浸透,若该层蛋糕的奶油能浸透的层数>temp,更新temp,temp=arr[i],每过一层 temp-- (temp>0),若temp>0则标记数组该位置true,最终原创 2021-05-04 09:38:17 · 166 阅读 · 0 评论 -
Increase and Copy
Increase and Copy2021.05.01 训练题I**题目大意:**给你一个数组a,a初始为 [ 1 ] ,给出数据n ,每次你可以选择一种操作:1.选择数组中任何一个数字进行复制,放到数组尾部 2.选择一个数字进行自增1操作 问最终需要最少多少步骤使得数组所有元素之和大于等于n**思路:**当从1开始复制时,步数为。。。当从2开始复制时,步数为。。。得出当从m开始复制时,步数最少,从m+1开始复制时,步数就开始增多,函数类似于对勾函数。原题:Initially, you ha原创 2021-05-04 09:29:02 · 44 阅读 · 0 评论 -
Ping-pong
Ping-pong Codeforces-1455C2021.05.01 训练题H题目大意: 两个角色 Alice 和 Bob 打球,第一次 Alice先发球,之后胜方发球,每个人都有自己的体力值,发球消耗1体力,回球消耗1体力(也可不接),每个人都想让自己胜场最大,问游戏结束后最后的胜场分别为多少思路: 理解误区:1.保证自己胜场最多并不意味着对方败场最多,也不意味着对方胜场最少 2.当一方体力为0后,比赛将结束,而不是另一方发球做题方法:若想让自己胜场最多,就无需关心对方是否胜利,也无需关心自原创 2021-05-02 21:57:34 · 157 阅读 · 0 评论 -
Spy Detected
Spy Detected Codeforces-1512A2021.05.01 训练题F题目大意: 给出一组数,找出与众不同的那个数的位置思路: 用三个数据记录,总有两个一样的一个不同的,然后找到不同的那个mark标记位置就可题目:You are given an array a consisting of n (n≥3) positive integers. It is known that in this array, all the numbers except one are the sa原创 2021-05-02 21:42:39 · 249 阅读 · 0 评论 -
Binary Removals
Binary Removals Codeforces-1499B2021.05.01 训练题E题目大意: 给定一个只有 ’ 0 ’ 和 ’ 1 ’ 组成的字符串,你可以删除任意位置的字符,但不能删除相邻的位置 (如,删除 index 处,则不能删除 index-1 和 index+1 的字符),问是否能在删除一些字符后得到一个递增的串(即:0…1…或0…或1…)思路: 其实相通了很简单,因为能删除任意位置的字符,所以 ’ 0 ’ 和 ’ 1 '不管在那个位置都无所谓,可以进行删除,但是限制条件就是相邻原创 2021-05-02 21:37:31 · 78 阅读 · 0 评论 -
Double-ended Strings
Double-ended Strings Codeforces-1506C2021.05.01 训练题D**题目大意:**给定一组(两行)字符串,两个字符串可以进行操作:从头部删除字符或者从尾部删除字符,找到最终两个字符串相等时删除的最小字符数**做题思路:**这道题考察两个字符串的最长公共子串,串的长度为20,可以暴力破解,将短的字符串分解成所有字串,然后在长串中找是否有,取长度最长的情况即可题目:You are given the strings a and b, consisting of原创 2021-05-02 21:26:53 · 95 阅读 · 0 评论 -
Corrupted Array
Corrupted Array Codeforces-1512D2021.05.01 训练题C**题目大意:**给你 n+2 个数字,是否能够找出有n个数字满足:n个数字的和等于另外一个数字(每个数字只用一次)**思路:**将数据存到数组 arr 中并从小到大排序,之后分情况讨论即可由于是升序排列,故n个数的和可能是 arr[n+2-1] 或 arr[n+2-2],即最后两项都有可能是最终的和1.当和为倒数第二项,此时前n项只可能是a[0]~a[n-1] (因为加最后一项一定大于倒数第二项)2.原创 2021-05-02 21:18:36 · 133 阅读 · 0 评论 -
A-B Palindrome
A-B Palindrome Codeforces-1512C2021.05.01 训练题B题目大意:给定一个长度为 a+b 的字符串,字符串中的字符用 ’ 0 ‘,’ 1 ‘,’ ? '三种组成,给定字符串中 ’ 0 ’ 和 ’ 1 ’ 的数量 a 和 b ,需要将字符串中的 ’ ? ’ 替换成 ’ 0 ’ 或 ’ 1 ’ ,问是否能该串转化成回文串做法:两次双指针遍历,第一次将对称位置更改成一致的,第二次将 ? 换成其他字符题目You are given a string s consisti原创 2021-05-02 21:07:45 · 64 阅读 · 0 评论 -
Almost Rectangle
Almost Rectangle2021.05.01 训练题A题目大意:有一个nxn的矩阵,矩阵中有两个标记 ’ * ’ ,添加另外两个标记使得其围成一个矩行思路:1.两个标记在同一行,则将另外两个标记分别放在这两个标记上方或下方2.两个标记在同一列,则将另外两个标记分别放在这两个标记左方或右方3.两个标记不在同一行或者同一列,若将两个已知标记的坐标获取到记为(x1,y1),(x2,y2),则另外两个标记的位置为(x1,y2),(x2,y1)There is a square field of原创 2021-05-02 20:58:27 · 81 阅读 · 0 评论 -
分考场
分考场算法dfs题目题目描述n个人参加某项特殊考试。为了公平,要求任何两个认识的人不能分在同一个考场。求最少需要分几个考场才能满足条件。输入第一行,一个整数n(1<n<100),表示参加考试的人数。第二行,一个整数m,表示接下来有m行数据以下m行每行的格式为:两个整数a,b,用空格分开 (1<=a,b<=n) 表示第a个人与第b个人认识(编号从1开始)。 输出一行一个整数,表示最少分几个考场。样例输入 Copy581 21 31 42 3原创 2020-11-29 13:51:56 · 144 阅读 · 0 评论 -
蓝桥:穿越雷区 bfs+队列
穿越雷区算法:bfs、队列题目:/** * X星的坦克战车很奇怪,它必须交替地穿越正能量辐射区和负能量辐射区才能保持正常运转,否则将报废。 * 某坦克需要从A区到B区去(A,B区本身是安全区,没有正能量或负能量特征),怎样走才能路径最短? * 已知的地图是一个方阵,上面用字母标出了A,B区,其它区都标了正号或负号分别表示正负能量辐射区。 * 例如: * A + - + - * - + - - + * - + + + - * + - + - + * B + - + - * 坦克车原创 2020-11-08 11:03:58 · 78 阅读 · 0 评论 -
Leecode:数组中的最长山脉
数组中的最长山脉难度:中等题目链接:https://leetcode-cn.com/problems/longest-mountain-in-array/题目: 我们把数组 A 中符合下列属性的任意连续子数组 B 称为 “山脉”: B.length >= 3 存在 0 < i < B.length - 1 使得 B[0] < B[1] < ... B[i-1] < B[i] > B[i+1] > ... > B[B.length -原创 2020-11-01 15:26:55 · 135 阅读 · 0 评论 -
两数相除
两数相除给定两个整数,被除数 dividend 和除数 divisor。将两数相除,要求不使用乘法、除法和 mod 运算符。返回被除数 dividend 除以除数 divisor 得到的商。整数除法的结果应当截去(truncate)其小数部分,例如:truncate(8.345) = 8 以及 truncate(-2.7335) = -2提示:被除数和除数均为 32 位有符号整数。除数不为 0。假设我们的环境只能存储 32 位有符号整数,其数值范围是 [−231, 231 − 1]。本题中,原创 2020-07-12 14:28:12 · 719 阅读 · 0 评论 -
跳水板
跳水板/**你正在使用一堆木板建造跳水板。有两种类型的木板,其中长度较短的木板长度为shorter,长度较长的木板长度为longer。你必须正好使用k块木板。编写一个方法,生成跳水板所有可能的长度。返回的长度需要从小到大排列。0 < shorter <= longer0 <= k <= 100000示例:输入:shorter = 1longer = 2k = 3输出: {3,4,5,6}来源:力扣(LeetCode)链接:https://leet原创 2020-07-12 14:24:55 · 100 阅读 · 0 评论 -
第七周训练 A - Fruits
A - FruitsThe spring is coming and it means that a lot of fruits appear on the counters. One sunny day little boy Valera decided to go shopping. He made a list of m fruits he wanted to buy. If Valera want to buy more than one fruit of some kind, he includ原创 2020-05-31 18:33:15 · 316 阅读 · 0 评论 -
数据库二次测试题目
数据库1.如何把这样一个表(表名aaa)结构的数据yearmouthamount199111.1199121.2199131.3199141.4199212.1199222.2199332.3199442.4查出这样的结果:yearm1m2m3m419911.11.21.31.419922.12.22.32.4答案:首先按照月份的不同查找amount,然后再按照原创 2020-05-24 18:34:02 · 1485 阅读 · 0 评论 -
二次测试
一:选择题1.以下关于静态方法和静态变量,说法正确的是()A. 静态方法不能调用实例方法或引用一个实例变量B. 实例方法不能调用静态方法或引用一个静态变量C. 静态方法可以互相调用D. 实例方法可以任意调用方法答案:...原创 2020-05-24 15:21:38 · 774 阅读 · 0 评论 -
A And B CodeForces - 1278B
A And BProblemYou are given two integers a and b. You can perform a sequence of operations: during the first operation you choose one of these numbers and increase it by 1; during the second operation you choose one of these numbers and increase it by 2,原创 2020-05-16 18:07:18 · 122 阅读 · 0 评论 -
National Project CodeForces - 1303B
National ProjectProblemYour company was appointed to lay new asphalt on the highway of length n. You know that every day you can either repair one unit of the highway (lay new asphalt over one unit ...原创 2020-05-04 20:28:42 · 97 阅读 · 0 评论 -
G - Worms CodeForces - 474B
G - WormsProblemIt is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains a i worms. He labeled all...原创 2020-05-04 20:23:17 · 135 阅读 · 0 评论 -
BerSU Ball CodeForces - 489B
BerSU BallProblemThe Berland State University is hosting a ballroom dance in celebration of its 100500-th anniversary! n boys and m girls are already busy rehearsing waltz, minuet, polonaise and qua...原创 2020-05-04 20:15:20 · 87 阅读 · 0 评论 -
Div Times Mod CodeForces - 1085B
Div Times ModProblemVasya likes to solve equations. Today he wants to solve (x div k)⋅(x mod k)=n, where div and mod stand for integer division and modulo operations (refer to the Notes below for ex...原创 2020-05-04 20:11:35 · 141 阅读 · 0 评论 -
Vitamins CodeForces - 1042B
VitaminsProblemBerland shop sells n kinds of juices. Each juice has its price ci. Each juice includes some set of vitamins in it. There are three types of vitamins: vitamin “A”, vitamin “B” and vita...原创 2020-05-04 20:03:14 · 197 阅读 · 0 评论 -
第二周训练 :F
F - Long NumberYou are given a long decimal number a consisting of n digits from 1 to 9. You also have a function f that maps every digit from 1 to 9 to some (possibly the same) digit from 1 to 9.Yo...原创 2020-04-26 19:40:56 · 110 阅读 · 0 评论 -
Alternating_Subsequence(Codeforces Round #636 (Div. 3) Problem C)
Alternating_SubsequenceCodeforce题目:C. Alternating Subsequencetime limit per test1 second memory limit per test256 megabytesRecall that the sequence b is a a subsequence of the sequence a if b can ...原创 2020-04-26 19:24:18 · 122 阅读 · 0 评论 -
第一周训练:I
IYou want to perform the combo on your opponent in one popular fighting game. The combo is the string s consisting of n lowercase Latin letters. To perform the combo, you have to press all buttons in...原创 2020-04-18 15:46:36 · 207 阅读 · 0 评论 -
第一周训练:C
CA number is ternary if it contains only digits 0, 1 and 2. For example, the following numbers are ternary: 1022, 11, 21, 2002.You are given a long ternary number x. The first (leftmost) digit of x ...原创 2020-04-18 15:28:00 · 82 阅读 · 0 评论 -
第一周训练:B
B CodeForces - 1328BFor the given integer n (n>2) let’s write down all the strings of length n which contain n−2 letters ‘a’ and two letters ‘b’ in lexicographical (alphabetical) order.Recall tha...原创 2020-04-18 15:17:32 · 152 阅读 · 0 评论 -
2013蓝桥杯JAVA A组题目总结
2013A组题一:题干/**2013A组题一:世纪末的星期:曾有邪教称1999年12月31日是世界末日还有人称今后的某个世纪末的12月31日,如果是星期一则会。。。有趣的是,任何一个世纪末的年份的12月31日都不可能是星期一于是,“谣言制造商”有修改为星期日。。。1999年的12月31日是星期五,请问:未来哪一个离我们最近的一个世纪末年(即xx99年)的12月31日正好...原创 2020-04-04 16:10:57 · 165 阅读 · 0 评论