算法
文章平均质量分 75
porridgexj
大三CS学生
展开
-
2021CCPC华为云挑战赛 1001 对象存储调度问题
1001 对象存储调度问题Problem Description题目背景:在华为云的对象存储调度过程中,我们会把数据对象存入分条中,而当数据对象较小时,我们会考虑聚合多个对象到一个分条中。如图所示:题目描述:给定 n 个大小 A1,A2,⋯,An 为 2 的整数次幂的数据对象,以及 m 个剩余空间为 B1,B2,⋯,Bm 的分条。问是否可以通过对数据对象进行聚合,使得能用现有的 m 个分条把所有 n 个对象存下来。T 组数据。Input第一行一个正整数 T(1≤T≤1000),表示数据组数。对原创 2021-08-31 18:47:28 · 324 阅读 · 0 评论 -
ICPC Greater New York Region 2020 E Marbles
E Marbles题目描述For a booth at the campus spring carnival, Toni wants to have players draw two marbles from a bowl of red and green marbles. Players go on to the next level of the game if one marble is red and one is green.Toni wants to be able to choose t原创 2021-08-30 21:19:18 · 166 阅读 · 0 评论 -
ICPC Greater New York Region 2020 L Evenly Separated Strings
L Evenly Separated Strings题目描述Given a string consisting of lowercase letters. We say the string is evenly separated if and only if there is an even number of characters between every pair of the same characters. For example, abba is evenly separated whil原创 2021-08-30 20:47:14 · 81 阅读 · 0 评论 -
2021中国大学生程序设计竞赛(CCPC)- 网络选拔赛 1009 Command Sequence
1009 Command SequenceProblem DescriptionThere is a robot that can move by receiving a sequence of commands.There are four types of command in the command sequence:U: robot moves one unit up.D: robot moves one unit down.L: robot moves one unit left.R原创 2021-08-29 10:52:59 · 713 阅读 · 0 评论 -
2021中国大学生程序设计竞赛(CCPC)- 网络选拔赛 1001 Cut The Wire
1001 Cut The WireProblem DescriptionIn the country of Infinity , there is a strange road. This road only has a starting point, but no end. Since this road is infinite, there are also countless street lights. The street lights are numbered from 1(the star原创 2021-08-29 10:27:16 · 486 阅读 · 0 评论 -
2021牛客暑期多校训练营9 H Happy Number
H Happy Number题目描述Digits 2, 3 and 6 are happy, while all others are unhappy. An integer is happy if it contains only happy digits in its decimal notation. For example, 2, 3, 263 are happy numbers, while 231 is not.Now Cuber QQ wants to know the n-th hap原创 2021-08-15 21:02:35 · 173 阅读 · 1 评论 -
AcWing 12. 背包问题求具体方案
AcWing 12. 背包问题求具体方案有 N 件物品和一个容量是 V 的背包。每件物品只能使用一次。第 i 件物品的体积是 vi,价值是 wi。求解将哪些物品装入背包,可使这些物品的总体积不超过背包容量,且总价值最大。输出 字典序最小的方案。这里的字典序是指:所选物品的编号所构成的序列。物品的编号范围是 1…N。输入格式输出一行,包含若干个用空格隔开的整数,表示最优解中所选物品的编号序列,且该编号序列的字典序最小。物品编号范围是 1…N。输出格式输出一个整数,表示方案数模10^9+7的结原创 2021-08-15 20:36:37 · 137 阅读 · 2 评论 -
AcWing 11. 背包问题求方案数
AcWing 11. 背包问题求方案数有 N 件物品和一个容量是 V 的背包。每件物品只能使用一次。第 i 件物品的体积是 vi,价值是 wi。求解将哪些物品装入背包,可使这些物品的总体积不超过背包容量,且总价值最大。输出 最优选法的方案数。注意答案可能很大,请输出答案模 10^9 + 7 的结果。输入格式第一行两个整数,N,V,用空格隔开,分别表示物品数量和背包容积。接下来有 N 行,每行两个整数 vi,wi,用空格隔开,分别表示第 i 件物品的体积和价值。输出格式输出一个整数,表示方案原创 2021-08-13 16:05:04 · 65 阅读 · 0 评论 -
2021“MINIEYE杯”中国大学生算法设计超级联赛(8)1003 Ink on paper
Ink on paperProblem DescriptionBob accidentally spilled some drops of ink on the paper. The initial position of the i-th drop of ink is (xi,yi), which expands outward by 0.5 centimeter per second, showing a circle.The curious Bob wants to know how long原创 2021-08-12 19:27:25 · 576 阅读 · 0 评论 -
小明看树 (反转二叉树 + 二叉树的左右视图)
小明看树 (反转二叉树 + 二叉树的左右视图)题目描述这一天小明放学回家没带钥匙,无聊的他只能在楼下来回踱步。这时他发现楼下种着一棵二叉树,他围着二叉树转了几圈,发现一颗二叉树从左边和从右边看到的数字是不一样的:对于图中的二叉树,他从左边能看到8 6 4 2 7,从右边可以看到8 5 1 2 7。这不禁让他陷入了思考:如果把每个节点的左右孩子都交换位置,从左边和从右边看到的数字会有什么变化呢?请帮助小明解决这个难题。输入描述第一行给定正整数n(1 ≤ n ≤ 10^3)和正整数x(1 ≤原创 2021-08-08 11:47:34 · 127 阅读 · 0 评论 -
AcWing 7. 混合背包问题
AcWing 7. 混合背包问题有 N 种物品和一个容量是 V 的背包。物品一共有三类:第一类物品只能用1次(01背包);第二类物品可以用无限次(完全背包);第三类物品最多只能用 si 次(多重背包);每种体积是 vi,价值是 wi。求解将哪些物品装入背包,可使物品体积总和不超过背包容量,且价值总和最大。输出最大价值。输入格式第一行两个整数,N,V,用空格隔开,分别表示物品种数和背包容积。接下来有 N 行,每行三个整数 vi,wi,si,用空格隔开,分别表示第 i 种物品的体积、价值和原创 2021-08-07 19:57:45 · 184 阅读 · 0 评论 -
AcWing 5. 多重背包问题 II
AcWing 5. 多重背包问题 II有 N 种物品和一个容量是 V 的背包。第 i 种物品最多有 si 件,每件体积是 vi,价值是 wi。求解将哪些物品装入背包,可使物品体积总和不超过背包容量,且价值总和最大。输出最大价值。输入格式第一行两个整数,N,V,用空格隔开,分别表示物品种数和背包容积。接下来有 N 行,每行三个整数 vi,wi,si,用空格隔开,分别表示第 i 种物品的体积、价值和数量。输出格式输出一个整数,表示最大价值。数据范围0<N≤10000<V≤20原创 2021-08-07 19:26:16 · 255 阅读 · 0 评论 -
ICPC Southeast USA 2020 Regional Contest Problem N Triangular Collection
N Triangular CollectionCall a set of positive integers triangular if it has size at least three and, for all triples of distinct integers from the set, a triangle with those three integers as side lengths can be constructed.Given a set of positive intege原创 2021-08-06 15:27:40 · 90 阅读 · 0 评论 -
ICPC Southeast USA 2020 Regional Contest Problem A Ant Typing
A Ant TypingConsider a configurable keyboard where keys can be moved about. An ant is walking on the top row of this keyboard and needs to type a numeric string. The ant starts on the leftmost key of the top row, which contains 9 keys, some permutation of原创 2021-08-06 14:52:42 · 189 阅读 · 0 评论 -
AcWing 99. 激光炸弹 (矩阵前缀和)
AcWing 99. 激光炸弹 (矩阵前缀和)地图上有 N 个目标,用整数 Xi,Yi 表示目标在地图上的位置,每个目标都有一个价值 Wi。注意:不同目标可能在同一位置。现在有一种新型的激光炸弹,可以摧毁一个包含 R×R 个位置的正方形内的所有目标。激光炸弹的投放是通过卫星定位的,但其有一个缺点,就是其爆炸范围,即那个正方形的边必须和 x,y 轴平行。求一颗炸弹最多能炸掉地图上总价值为多少的目标。输入格式第一行输入正整数 N 和 R,分别代表地图上的目标数目和正方形的边长,数据用空格隔开。接原创 2021-08-01 17:24:40 · 803 阅读 · 4 评论 -
ICPC Southeast USA 2020 Regional Contest Problem P Unread Messages
P Unread MessagesThere is a group of people in an internet email message group. Messages are sent to all membersof the group, and no two messages are sent at the same time.Immediately before a person sends a message, they read all their unread messages原创 2021-08-01 17:04:32 · 101 阅读 · 0 评论 -
ICPC Southeast USA 2020 Regional Contest Problem F Exam Manipulation (二进制枚举)
Color the blocksA group of students is taking a True/False exam. Each question is worth one point. You, as theirteacher, want to make your students look as good as possible—so you cheat! (I know, you wouldnever actually do that.) To cheat, you manipulat原创 2021-08-01 16:29:27 · 103 阅读 · 0 评论 -
AtCoder Beginner Contest 212 C - Min Difference
C - Min DifferenceProblem StatementYou are given two sequences: A=(A1,A2,…,AN) consisting of N positive integers, and B=(B1,…,BM) consisting of M positive integers.Find the minimum difference of an element of A and an element of B, that is, min1≤i≤N min原创 2021-08-01 15:25:14 · 194 阅读 · 0 评论 -
AtCoder Beginner Contest 212 D - Querying Multiset (优先队列)
D - Querying MultisetProblem StatementTakahashi has many balls, on which nothing is written, and one bag. Initially, the bag is empty. Takahashi will do Q operations, each of which is of one of thefollowing three types.Type 1: Write an integer Xi on a原创 2021-08-01 14:50:03 · 181 阅读 · 0 评论 -
AcWing 101. 最高的牛 (差分+前缀和)
最高的牛有 N 头牛站成一行,被编队为 1、2、3…N,每头牛的身高都为整数。当且仅当两头牛中间的牛身高都比它们矮时,两头牛方可看到对方。现在,我们只知道其中最高的牛是第 P 头,它的身高是 H ,剩余牛的身高未知。但是,我们还知道这群牛之中存在着 M 对关系,每对关系都指明了某两头牛 A 和 B 可以相互看见。求每头牛的身高的最大可能值是多少。输入格式第一行输入整数 N,P,H,M,数据用空格隔开。接下来 M 行,每行输出两个整数 A 和 B ,代表牛 A 和牛 B 可以相互看见,数据用空原创 2021-07-25 20:39:36 · 283 阅读 · 1 评论 -
HDU - 6934 Color the blocks
Color the blocksProblem StatementThere are N candies arranged in a row from left to right.Each of these candies has one color that is one of the 109 colors called Color 1, Color 2, …, and Color 109.For each i=1,2,…,N, the color of the i-th candy from t原创 2021-07-25 20:18:28 · 131 阅读 · 0 评论 -
2021牛客暑期多校训练营1 F Find 3-friendly Integers
F Find 3-friendly Integers题目描述A positive integer is 3-friendly if and only if we can find a continuous substring in its decimal representation, and the decimal integer represented by the substring is a multiple of 3.For instance:104 is 3-friendly becau原创 2021-07-25 19:48:00 · 88 阅读 · 0 评论 -
AtCoder Beginner Contest 210 C - Colorful Candies
C - Colorful CandiesProblem StatementThere are N candies arranged in a row from left to right.Each of these candies has one color that is one of the 109 colors called Color 1, Color 2, …, and Color 109.For each i=1,2,…,N, the color of the i-th candy fr原创 2021-07-19 14:41:40 · 187 阅读 · 0 评论 -
Codeforces Round #733 (Div. 1 + Div. 2, based on VK Cup 2021 - Elimination (Engine)) C. Pursuit
C. PursuitDescriptionYou and your friend Ilya are participating in an individual programming contest consisting of multiple stages. A contestant can get between0 and 100 points, inclusive, for each stage, independently of other contestants.Points recei原创 2021-07-18 09:57:21 · 432 阅读 · 0 评论 -
Codeforces Round #732 (Div. 2) B. AquaMoon and Stolen String
A. AquaMoon and Two ArraysDescriptionAquaMoon and Cirno are playing an interesting game with arrays. Cirno has prepared two arrays a and b, both consist of n non-negativeintegers. AquaMoon can perform the following operation an arbitrary number of times原创 2021-07-17 16:11:45 · 132 阅读 · 0 评论 -
Codeforces Round #732 (Div. 2) A. AquaMoon and Two Arrays
A. AquaMoon and Two ArraysDescriptionAquaMoon and Cirno are playing an interesting game with arrays. Cirno has prepared two arrays a and b, both consist of n non-negativeintegers. AquaMoon can perform the following operation an arbitrary number of times原创 2021-07-17 15:50:56 · 245 阅读 · 0 评论 -
Codeforces Round #728 (Div. 2) B - Pleasant Pairs
B - Pleasant PairsDescriptionYou are given an array a1, a2, …, an consisting of n distinct integers. Count the number of pairs of indices (i, j) such that i < j and ai ⋅ aj = i + j.InputThe first line contains one integer t (1 ≤ t ≤ 10^4) — the numb原创 2021-06-28 22:12:53 · 234 阅读 · 1 评论 -
2020-2021年度第二届全国大学生算法设计与编程挑战赛(春季赛)C-这是一道大难题(一条边固定的最小生成树)
C - 这是一道大难题Description李华同学遇到一个大难题:当前有n个节点散落在地图上,而地图上有m条无向的边连接了这些节点。他需要解决的问题是,在固定一条必须要选择的边的情况下,再选择剩下的边将所有点连接成一颗树。现在请问这颗树的最小路径和是多少。因为李华答应你如果你写出了这道题就送你一个优菈,所以请尽力帮他解决这个问题吧!Input第一行给出n,m表示n个点,m条边。接下来m行给出x,y,z表示一条路径连接x,y两点,长度为z。接下来一行给定必须要选择一条边。O原创 2021-06-14 22:19:04 · 411 阅读 · 1 评论 -
第十一届山东省大学生程序设计竞赛H-Adventurer‘s Guild(二维费用的背包问题)
H-Adventurer’s Guild题目描述:Yuna traveled into the fantasy world. The gods of this world gave her a powerful set of equipment so that she could defeat many fierce monsters. However, she had limited health points and stamina, and she could not kill a large n原创 2021-06-14 21:07:56 · 672 阅读 · 3 评论