自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

转载 多线程问题

多线程问题文章http://www.360doc.com/content/21/0415/23/58006001_972536715.shtml

2021-09-13 20:53:37 144

原创 面试题:Leetcode 寻找两个正序数组的中位数

题目链接给定两个大小分别为 m 和 n 的正序(从小到大)数组 nums1 和 nums2。请你找出并返回这两个正序数组的 中位数 。示例 1:输入:nums1 = [1,3], nums2 = [2]输出:2.00000解释:合并数组 = [1,2,3] ,中位数 2示例 2:输入:nums1 = [1,2], nums2 = [3,4]输出:2.50000解释:合并数组 = [1,2,3,4] ,中位数 (2 + 3) / 2 = 2.5示例 3:输入:nums1 = [0,

2021-04-20 08:48:49 300

原创 牛客练习赛60 C-操作集锦 【动态规划】

传送门:C-操作集锦题目描述有一款自走棋有26种操作,每种操作我们都用 a,b,c,d,…,x,y,z 的符号来代替.现在牛牛有一个长度为nn的操作序列,他现在可以从里面拿出某些操作来组合成一个操作视频, 比如说操作序列是abcdabcd,那么操作视频就有a,b,c,d,ab,ac,ad 等(也就是操作序列的子序列).他现在想知道长度为k且本质不同的操作视频有多少种.比如对于aba...

2020-03-29 15:37:52 272

原创 牛客练习赛60 B-三角形周长和 【暴力】

B-三角形周长和 解题思路:因为n是1000,所以直接 O(n2) 去枚举所有边,那么每一条边显然会在其他n−2个三角形中出现,这个就是这条边的贡献系数,这题就算完了。AC代码:#include<iostream>#include<algorithm>#include<cstring>#include<cstdio>#inc...

2020-03-28 18:34:11 188

原创 牛客练习赛60 A-大吉大利 【思维】

传送门:A-大吉大利.链接:https://ac.nowcoder.com/acm/contest/4853/A来源:牛客网题目描述给定n个整数,依次为a1 ,a2​,…,an。求∑i=1n∑j=1n(ai&aj)\sum_{i = 1}^n\sum_{j = 1}^n(a_i\&a_j)∑i=1n​∑j=1n​(ai​&aj​)。“&”是二进制的...

2020-03-28 17:26:19 196

原创 HDU 5573 Binary Tree 【二进制+思维】

传送门:HDU 5573Binary TreeProblem DescriptionThe Old Frog King lives on the root of an infinite tree. According to the law, each node should connect to exactly two nodes on the next level, forming...

2020-03-19 15:43:08 151

原创 HDU 5583 Kingdom of Black and White 【贪心】

传送门:HDU 5583Kingdom of Black and WhiteProblem DescriptionIn the Kingdom of Black and White (KBW), there are two kinds of frogs: black frog and white frog.Now N frogs are standing in a line, so...

2020-03-19 15:13:42 159

原创 HDU 5584 LCM Walk 【数学+思维+逆推】

HDU 5584LCM Walk Problem DescriptionA frog has just learned some number theory, and can’t wait to show his ability to his girlfriend.Now the frog is sitting on a grid map of infinite rows and ...

2020-03-15 21:45:16 299

原创 Codeforces 1325B CopyCopyCopyCopyCopy

传送门:Codeforces 1325B按照题意,我们可以无限复制所给的字符串,要求我们找最长递增子序列的长度。结合样例,我们不难发现,最长的长度就是将所给数组排序、去重后的长度。所以用一个 set 存数组即可。AC代码:#include<iostream>#include<algorithm>#include<cstring>#inclu...

2020-03-15 00:33:48 731

原创 Codeforces 1325A EhAb AnD gCd

传送门:Codeforces 1325A要满足 GCD(a,b)+LCM(a,b)=x ,只要 a=1,b=x-1 即可。AC代码:#include<iostream>#include<algorithm>#include<cstring>#include<cstdio>#include<cmath>#defin...

2020-03-15 00:22:52 395

原创 Codeforces 1312B Bogosort

传送门:Codeforces 1312BB. BogosortYou are given an array a1,a2,…,an. Array is good if for each pair of indexes i<j the condition j−aj≠i−ai holds. Can you shuffle this array so that it becomes go...

2020-03-11 18:38:20 453

原创 Codeforces 1312A

Codeforces 1312A签到题,当 n 可以被 m 整除时,输出 YES,否则 NO。AC代码:#include<iostream>#include<algorithm>#include<cstring>#include<cstdio>#include<cmath>#define ll long long#d...

2020-03-11 17:19:38 151

原创 PAT练习题 甲级P1029 Median (25分)【求中位数】

传送门:P1029将两个序列合并,分奇偶找中值AC代码:#include<iostream>#include<algorithm>#include<cstring>#define ll long longusing namespace std;const int N=1e6+10;int n;ll num[N];int main(...

2020-03-05 18:55:25 214

原创 PAT练习题 甲级P1028

传送门:P1028AC代码:#include<iostream>#include<algorithm>#include<cstring>#include<cstdio>#include<string>#define ll long longusing namespace std;int n,c;struct st...

2020-03-05 18:34:19 143

原创 PAT练习题 P1027 Colors in Mars (20分)【进制转换】

传送门:P1027就是将给你的三个十进制的数转换成十三进制输出。AC代码:#include<iostream>#include<algorithm>#include<cstring>#include<cstdio>#include<cmath>#define ll long long#define inf 0x...

2020-03-05 18:07:25 127

原创 PAT练习题 P1025 PAT Ranking (25分)【结构体水题】

传送门:P1025水题,构造一个结构体,存下 考生id ,组号,成绩。每组输入结束都进行一次排序,将每组的排名记下。最后再进行一次排序,将最终成绩记下。AC代码:#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using nam...

2020-03-04 20:34:46 151

原创 PAT练习题 P1021 Deepest Root (25分)【并查集+图的遍历】

传送门:P1021Deepest Root (25分)A graph which is connected and acyclic can be considered a tree. The height of the tree depends on the selected root. Now you are supposed to find the root that result...

2020-03-03 15:51:23 170

原创 Codeforces 1321C Remove Adjacent 【贪心】

Codeforces 1321CRemove AdjacentYou are given a string s consisting of lowercase Latin letters. Let the length of s be |s|. You may perform several operations on this string.In one operation, yo...

2020-03-02 22:16:57 313

原创 Codeforces 1321B Journey Planning 【思维】

传送门:Codeforces 1321BJourney Planningtime limit per test: 2 secondsmemory limit per test: 256 megabytesTanya wants to go on a journey across the cities of Berland. There are n cities situated a...

2020-03-02 17:19:08 550

原创 Codeforces 1321A Contest for Robots

传送门:Codeforces 1321A题目大意:两个公司 R 和 B 进行比赛,我们希望 R 公司赢。以答题的形式来得分,事先告诉你每个公司可以完成的工作 1表示可以完成,0则反之。我们可以通过暗箱操作的方式调整题目的分数,来使 R 公司胜利,但是为了避免不会太假,所以要求我们题目的最高分要尽量小。解题思路:去除两个公司都能得分的题目,剩下 B 公司可以完成的 x 题都以最小分...

2020-03-02 16:57:06 640

原创 PAT练习题 P1119 Pre- and Post-order Traversals (30分)【二叉树遍历】

传送门:P1119Pre- and Post-order Traversals (30分)Suppose that all the keys in a binary tree are distinct positive integers. A unique binary tree can be determined by a given pair of postorder and in...

2020-03-02 12:46:16 554

原创 PAT练习题 P1020 Tree Traversals (25分)【树的遍历】

传送门:P1020P1020 Tree Traversals (25分)Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to output the...

2020-02-28 01:17:57 253

原创 PAT练习题 P1018 Public Bike Management (30分) 【单源最短路】

传送门:P10181018 Public Bike Management (30分)There is a public bike service in Hangzhou City which provides great convenience to the tourists from all over the world. One may rent a bike at any sta...

2020-02-26 22:44:02 241

原创 PAT练习题 P1014 Waiting in Line (30分) 【队列模拟】

传送门:P1014P1014 Waiting in Line (30分)Suppose a bank has N windows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. The rules for the...

2020-02-25 16:48:07 364

原创 PAT练习题 P1013 Battle Over Cities (25分) 【图的连通】

传送门: P1013P1013 Battle Over Cities (25分)It is vitally important to have all the cities connected by highways in a war. If a city is occupied by the enemy, all the highways from/toward that city ...

2020-02-24 17:36:29 298

原创 PAT练习题 P1012 The Best Rank (25分) 【结构体运用】

传送门:P1012P1012 The Best Rank (25分)To evaluate the performance of our first year CS majored students, we consider their grades of three courses only: C - C Programming Language, M - Mathematics (...

2020-02-24 11:14:58 205

原创 PAT练习题 P1010 Radix (25分)【二分匹配】

传送门:P1010P1010 Radix (25分)Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is yes, if 6 is a decimal number and 110 is a binary number.No...

2020-02-23 22:28:12 203

原创 PAT练习题 1009 Product of Polynomials(25分)多项式乘法

传送门:10091009 Product of Polynomials (25分)This time, you are supposed to find A×B where A and B are two polynomials.Input Specification:Each input file contains one test case. Each case occupie...

2020-02-23 16:29:33 226

原创 PAT练习题 1004 Counting Leaves (30分)

传送门:10041004 Counting Leaves (30分)A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child.Input Specification:Each input file con...

2020-02-08 16:57:25 282

原创 PTA练习题 1003 Emergency (25分) 【dfs最短路】

传送门:10031003 Emergency (25分)As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of r...

2020-01-21 15:50:51 262

原创 Codeforces 1256E Yet Another Division Into Teams 【dp】

传送门:Codeforces 1256EYet Another Division Into Teamstime limit per test: 2 secondsThere are n students at your university. The programming skill of the i-th student is ai. As a coach, you want t...

2019-11-21 11:09:43 195

原创 堆排序算法个人理解

一、基础知识堆的结构可以分为大根堆和小根堆,是一个完全二叉树,而堆排序是根据堆的这种数据结构设计的一种排序。完全二叉树(Complete Binary Tree): 除了最后一层之外的其他每一层都被完全填充,并且所有结点都保持向左对齐。1.1 大根堆和小根堆大根堆:每个结点的值都大于其左孩子和右孩子结点的值。小根堆:每个结点的值都小于其左孩子和右孩子结点的值。2.2 查找数...

2019-11-18 21:03:35 232

原创 Codeforces 1257D Yet Another Monster Killing Problem【贪心】

传送门:Codeforces 1257DD.Yet Another Monster Killing Problemtime limit per test: 2 secondsYou play a computer game. In this game, you lead a party of m heroes, and you have to clear a dungeon with...

2019-11-15 21:51:24 694

原创 P4290 玩具取名 【区间dp】

传送门:P4290题目描述某人有一套玩具,并想法给玩具命名。首先他选择WING四个字母中的任意一个字母作为玩具的基本名字。然后他会根据自己的喜好,将名字中任意一个字母用“WING”中任意两个字母代替,使得自己的名字能够扩充得很长。现在,他想请你猜猜某一个很长的名字,最初可能是由哪几个字母变形过来的。输入格式第一行四个整数W、I、N、G。表示每一个字母能由几种两个字母所替代。接下...

2019-11-03 16:20:14 199

原创 JSOI2010 满汉全席 【2-SAT】

传送门:题目链接满汉全席题目描述满汉全席是中国最丰盛的宴客菜肴,有许多种不同的材料透过满族或是汉族的料理方式,呈现在數量繁多的菜色之中。由于菜色众多而繁杂,只有极少數博学多闻技艺高超的厨师能够做出满汉全席,而能够烹饪出经过专家认证的满汉全席,也是中国厨师最大的荣誉之一。世界满汉全席协会是由能够料理满汉全席的专家厨师们所组成,而他们之间还细分为许多不同等级的厨师。为了招收新进的厨师进...

2019-10-30 09:34:16 163

原创 洛谷P2989 Need For Speed 【贪心】

传送门:洛谷 P2989牛客题目链接 Need For Speed题目描述:Bessie is preparing her race car for the upcoming Grand Prix, but she wants to buy some extra parts to improve the car’s performance. Her race car current...

2019-10-28 20:25:49 170

原创 Codeforces 1249E By Elevator or Stairs?【dp】

传送门:By Elevator or Stairs?By Elevator or Stairs?You are planning to buy an apartment in a n-floor building. The floors are numbered from 1 to n from the bottom to the top. At first for each floo...

2019-10-27 13:34:02 383

原创 Codeforces 1249D2 Too Many Segments (hard version) 【贪心】

传送门:Codeforces 1249D2Too Many Segments (hard version)time limit per test: 2 secondsmemory limit per test: 256 megabytesYou are given n segments on the coordinate axis OX. Segments can intersec...

2019-10-25 21:23:42 673 1

原创 深信服2019春招 下棋题解【dfs】

传送门:下棋下棋8x8的棋盘上,布有黑白两色棋子,白子先下,当白子下N手后,棋盘上最多有可能留下多少颗白子?下法规则:1.每次落子后,以该棋子为中心的8个方向(米字形的8条直线),如果有同色棋子,且两个同色棋子之间连续排列着若干个异色棋子,无空白及同色棋子。则,这次落子可以把这些夹在中间的异色棋子全部翻色(即黑变白,白变黑)。黑白子交错落子。如果一个位置上有棋子,不能...

2019-10-24 16:12:32 1616 1

原创 POJ 1113 Wall 【裸的凸包算法模板题】

传送门:POJ 1113WallTime Limit: 1000MS Memory Limit: 10000KProblem DescriptionOnce upon a time there was a greedy King who ordered his chief Architect to build a wall around the King’s castle. Th...

2019-10-16 15:23:35 144

空空如也

空空如也

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

TA关注的人

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