自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(369)
  • 收藏
  • 关注

原创 力扣训练——搜索

本篇参照大佬博客练习题顺序,代码都是自打的,有些可能不是最优解。1091. 二进制矩阵中的最短路径class Solution {public: struct node{ int x; int y; int s; }; int shortestPathBinaryMatrix(vector<vector<int>>& grid) { queue<node>q;

2021-01-31 14:51:46 330 1

原创 力扣训练——位运算

本篇参照大佬博客练习题顺序,代码都是自打的,有些可能不是最优解。461. 汉明距离class Solution {public: int hammingDistance(int x, int y) { int ans=x^y,s=0; while(ans) { if(ans%2==1) s++; ans/=2; } return s;

2021-01-28 19:32:56 296

原创 力扣训练——二分

本篇参照大佬博客练习题顺序,代码都是自打的,有些可能不是最优解。69. x 的平方根class Solution {public: int mySqrt(int x) { long long l=1,r=x; while(l<=r) { long long mid=(l+r)/2; if(mid*mid>x) { r=mid-

2021-01-27 13:24:12 262

原创 力扣训练——动态规划

本篇参照大佬博客练习题顺序,代码都是自打的,有些可能不是最优解。70. 爬楼梯class Solution {public: int climbStairs(int n) { int dp[n+10]; dp[1]=1; dp[2]=2; for(int i=3;i<=n;i++) { dp[i]=dp[i-1]+dp[i-2]; } return

2021-01-27 08:26:56 532

原创 力扣训练——贪心

本篇参照大佬博客练习题顺序,代码都是自打的,有些可能不是最优解。455. 分发饼干class Solution {public: int findContentChildren(vector<int>& g, vector<int>& s) { sort(g.begin(),g.end()); sort(s.begin(),s.end()); int r=g.size()-1; int

2021-01-25 14:22:24 125

原创 力扣训练——数论

本篇参照大佬博客练习题顺序,代码都是自打的,有些可能不是最优解。目录204. 计数质数504. 七进制数405. 数字转换为十六进制数168. Excel表列名称172. 阶乘后的零67. 二进制求和415. 字符串相加462. 最少移动次数使数组元素相等 II169. 多数元素367. 有效的完全平方数326. 3的幂238. 除自身以外数组的乘积628. 三个数的最大乘积204. 计数质数class Solution {public:

2021-01-24 15:57:50 173 1

原创 C - Digital Path

https://nanti.jisuanke.com/t/42397Zhe the bully, is condemned by all kinds of evil, like bullying those who are weaker. His teammates have been mistreated for a long time. Finally, they decided not to put up with their buddy any more and flee to Digital V

2020-12-20 14:33:17 204

原创 M - Gitignore

https://codeforces.com/gym/102900/problem/MYour git project (you don’t need to be familiar with git to solve this problem) has some files that should be ignored from synchronizing. You need to calculate the minimum number of lines needed for gitignore.Fo

2020-12-19 20:30:08 418 1

原创 D - Meaningless Sequence

https://codeforces.com/gym/102832/problem/DOnce there was a mathematician, who was obsessed with meaningless number sequences. Here is one of them.an={1,c⋅max0≤i<nan&i,n=0otherwise,an={1,n=0c⋅max0≤i<nan&⁡i,otherwise,where&&...

2020-12-15 18:56:32 298

原创 K - Ragdoll

https://codeforces.com/gym/102832/problem/KOnce there was a lovely ragdoll cat, named Little Zara, who liked trees and math. One day she met the doge Adam. Adam had just planted some trees each consisting of only one node. The nodes were numbered from11.

2020-12-15 18:50:37 325

原创 D. XOR-gun

https://codeforces.ml/contest/1457/problem/DArkady owns anon-decreasingarraya1,a2,…,ana1,a2,…,an. You are jealous of its beauty and want to destroy this property. You have a so-calledXOR-gunthat you can use one or more times.In one step you can se...

2020-11-29 18:36:22 377 1

原创 C. Bouncing Ball

https://codeforces.ml/contest/1457/problem/CYou're creating a game level for some mobile game. The level should contain some number of cells aligned in a row from left to right and numbered with consecutive integers starting from11, and in each cell you.

2020-11-29 17:21:20 271

原创 C. Sequence Transformation

https://codeforces.ml/contest/1454/problem/CYou are given a sequenceaa, initially consisting ofnnintegers.You want to transform this sequence so that all elements in itare equal(i.e. it contains several occurrences of the same element).To achie...

2020-11-25 15:12:51 473

原创 D. Number into Sequence

https://codeforces.ml/contest/1454/problem/DYou are given an integernn(n>1n>1).Your task is to find a sequence of integersa1,a2,…,aka1,a2,…,aksuch that:eachaiaiis strictly greater than11; a1⋅a2⋅…⋅ak=na1⋅a2⋅…⋅ak=n(i.e. the product of t...

2020-11-25 15:11:08 558 2

原创 C. ABBB

https://codeforces.ml/contest/1428/problem/CZookeeper is playing a game. In this game, Zookeeper must use bombs to bomb a string that consists of letters 'A' and 'B'. He can use bombs to bomb a substring which is either "AB" or "BB". When he bombs such a

2020-11-24 15:11:57 456

原创 B. Toy Blocks

https://codeforces.ml/contest/1452/problem/BYou are asked to watch your nephew who likes to play with toy blocks in a strange way.He hasnnboxes and theii-th box hasaiaiblocks. His game consists of two steps:he chooses an arbitrary boxii; he tr...

2020-11-23 17:04:48 279 1

原创 D. Radio Towers

https://codeforces.ml/contest/1452/problem/DThere aren+2n+2towns located on a coordinate line, numbered from00ton+1n+1. Theii-th town is located at the pointii.You build a radio tower in each of the towns1,2,…,n1,2,…,nwith probability1212(th...

2020-11-23 17:03:48 327

原创 C. String Equality

https://codeforces.com/contest/1451/problem/CAshish has two stringsaaandbb, each of lengthnn, and an integerkk. The strings only contain lowercase English letters.He wants to convert stringaainto stringbbby performing some (possibly zero) oper...

2020-11-22 14:37:39 313 1

原创 C. k-Amazing Numbers

https://codeforces.ml/contest/1417/problem/CYou are given an arrayaaconsisting ofnnintegers numbered from11tonn.Let's define thekk-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having lengt...

2020-11-19 14:29:07 260

原创 B. Sum of Medians

https://codeforces.ml/contest/1440/problem/BAmedianof an array of integers of lengthnnis the number standing on the⌈n2⌉⌈n2⌉(rounding up) position in the non-decreasing ordering of its elements. Positions are numbered starting with11. For example, ...

2020-11-18 14:12:58 312

原创 C2. Binary Table (Hard Version)

https://codeforces.ml/contest/1440/problem/C2This is the hard version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both versions of the problem.

2020-11-18 13:52:37 312

原创 D. Catching Cheaters

https://codeforces.ml/contest/1447/problem/DYou are given two stringsAAandBBrepresenting essays of two students who are suspected cheaters. For any two stringsCC,DDwe define their similarity scoreS(C,D)S(C,D)as4⋅LCS(C,D)−|C|−|D|4⋅LCS(C,D)−|C|−|...

2020-11-16 19:42:46 232

原创 C. Knapsack

https://codeforces.ml/contest/1447/problem/CYou have a knapsack with the capacity ofWW. There are alsonnitems, theii-th one has weightwiwi.You want to put some of these items into the knapsack in such a way that their total weightCCis at least h...

2020-11-16 18:35:16 262

原创 C. Engineer Artem

https://codeforces.ml/contest/1438/problem/CArtem is building a new robot. He has a matrixaaconsisting ofnnrows andmmcolumns. The cell located on theii-th row from the top and thejj-th column from the left has a valueai,jai,jwritten in it.If ...

2020-11-14 14:22:31 197

原创 D. Minimal Height Tree

https://codeforces.ml/contest/1437/problem/DMonocarp had a tree which consisted ofnnvertices and was rooted at vertex11. He decided to study BFS (Breadth-first search), so he ran BFS on his tree, starting from the root. BFS can be described by the fol...

2020-11-06 14:41:55 203

原创 C. Chef Monocarp

Chef Monocarp has just putnndishes into an oven. He knows that theii-th dish has its optimal cooking time equal totitiminutes.At anypositive integerminuteTTMonocarp can putno more than onedish out of the oven. If theii-th dish is put out at s...

2020-11-06 14:40:36 228

原创 C. Division

https://codeforces.ml/contest/1445/problem/COleg's favorite subjects are History and Math, and his favorite branch of mathematics is division.To improve his division skills, Oleg came up withttpairs of integerspipiandqiqiand for each pair decided...

2020-11-05 16:45:17 217

原创 D. Extreme Subtraction

链接:https://codeforces.ml/contest/1443/problem/DYou are given an arrayaaofnnpositive integers.You can use the following operation as many times as you like: select any integer1≤k≤n1≤k≤nand do one of two things:decrement by onekkof the first el...

2020-11-05 13:48:27 182

原创 C - Play a game

New Year is Coming!ailyanlu is very happy today! and he is playing a chessboard game with 8600.The size of the chessboard is n*n. A stone is placed in a corner square. They play alternatively with 8600 having the first move. Each time, player is allowed

2020-10-24 10:46:33 193

原创 G - 邂逅明下

当日遇到月,于是有了明。当我遇到了你,便成了侣。那天,日月相会,我见到了你。而且,大地失去了光辉,你我是否成侣?这注定是个凄美的故事。(以上是废话)小t和所有世俗的人们一样,期待那百年难遇的日食。驻足街头看天,看日月渐渐走近,小t的脖子那个酸呀(他坚持这个姿势已经有半个多小时啦)。他低下仰起的头,环顾四周。忽然发现身边竟站着位漂亮的mm。天渐渐暗下,这mm在这街头竟然如此耀眼,她是天使吗?站着小t身边的天使。小t对mm惊呼:“缘分呐~~”。mm却毫不含糊:“是啊,500年一遇哦!”(此后省略5000字

2020-10-24 10:22:06 103

原创 S - 取(2堆)石子游戏

有两堆石子,数量任意,可以不同。游戏开始由两个人轮流取石子。游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子;二是可以在两堆中同时取走相同数量的石子。最后把石子全部取完者为胜者。现在给出初始的两堆石子的数目,如果轮到你先取,假设双方都采取最好的策略,问最后你是胜者还是败者。如果你胜,你第1次怎样取子?Input输入包含若干行,表示若干种石子的初始情况,其中每一行包含两个非负整数a和b,表示两堆石子的数目,a和b都不大于1,000,000,且a<=b。a=b=0退出。O

2020-10-23 14:31:53 192

原创 R - 取石子游戏

https://vjudge.net/contest/402733#problem/R有两堆石子,数量任意,可以不同。游戏开始由两个人轮流取石子。游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子;二是可以在两堆中同时取走相同数量的石子。最后把石子全部取完者为胜者。现在给出初始的两堆石子的数目,如果轮到你先取,假设双方都采取最好的策略,问最后你是胜者还是败者。Input输入包含若干行,表示若干种石子的初始情况,其中每一行包含两个非负整数a和b,表示两堆石子的数目,a和b都不大

2020-10-23 14:21:11 140

原创 F - 取石子游戏

1堆石子有n个,两人轮流取.先取者第1次可以取任意多个,但不能全部取完.以后每次取的石子数不能超过上次取子数的2倍。取完者胜.先取者负输出"Second win".先取者胜输出"First win".Input输入有多组.每组第1行是2<=n<2^31. n=0退出.Output先取者负输出"Second win". 先取者胜输出"First win".参看Sample Output.Sample Input213100000Sample Output

2020-10-23 13:47:50 149

原创 J - Kingdom‘s Power

https://vjudge.net/contest/402960#problem/JAlex is a professional computer game player.These days, Alex is playing a war strategy game. The kingdoms in the world form a rooted tree. Alex's kingdom11is the root of the tree. With his great diplomacy an..

2020-10-22 19:46:45 329

原创 E - Island Transport

https://vjudge.net/contest/402729#problem/EIn the vast waters far far away, there are many islands. People are living on the islands, and all the transport among the islands relies on the ships.  You have a transportation company there. Some routes are

2020-10-21 17:58:02 106

原创 G - Control

https://vjudge.net/contest/402729#problem/G  You, the head of Department of Security, recently received a top-secret information that a group of terrorists is planning to transport some WMD1from one city (the source) to another one (the destination). Y..

2020-10-21 14:17:15 176

原创 F - Food

https://vjudge.net/contest/402729#problem/FYou, a part-time dining service worker in your college’s dining hall, are now confused with a new problem: serve as many people as possible.  The issue comes up as people in your college are more and more diffi

2020-10-21 12:02:02 277

原创 B - Dining

https://vjudge.net/contest/402729#problem/BCows are such finicky eaters. Each cow has a preference for certain foods and drinks, and she will consume no others.Farmer John has cooked fabulous meals for his cows, but he forgot to check his menu against

2020-10-21 10:42:25 106

原创 M - 非常可乐

https://vjudge.net/contest/402204#problem/M大家一定觉的运动以后喝可乐是一件很惬意的事情,但是seeyou却不这么认为。因为每次当seeyou买了可乐以后,阿牛就要求和seeyou一起分享这一瓶可乐,而且一定要喝的和seeyou一样多。但seeyou的手中只有两个杯子,它们的容量分别是N 毫升和M 毫升 可乐的体积为S (S<101)毫升 (正好装满一瓶) ,它们三个之间可以相互倒可乐 (都是没有刻度的,且 S==N+M,101>S>0,N>0,M>0)

2020-10-19 16:11:15 130

原创 F - Prime Path

https://vjudge.net/contest/402204#problem/FThe ministers of the cabinet were quite upset by the message from the Chief of Security stating that they would all have to change the four-digit room numbers on their offices.— It is a matter of security to ch

2020-10-19 15:16:15 137

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除