- 博客(91)
- 收藏
- 关注
原创 L2-032 彩虹瓶 (25 分)
L2-032 彩虹瓶 (25 分)彩虹瓶的制作过程(并不)是这样的:先把一大批空瓶铺放在装填场地上,然后按照一定的顺序将每种颜色的小球均匀撒到这批瓶子里。假设彩虹瓶里要按顺序装 N 种颜色的小球(不妨将顺序就编号为 1 到 N)。现在工厂里有每种颜色的小球各一箱,工人需要一箱一箱地将小球从工厂里搬到装填场地。如果搬来的这箱小球正好是可以装填的颜色,就直接拆箱装填;如果不是,就把箱子先码放在一个临时货架上,码放的方法就是一箱一箱堆上去。当一种颜色装填完以后,先看看货架顶端的一箱是不是下一个要装填的
2022-04-17 16:12:41
170
原创 L2-022 重排链表 (25 分)
L2-022 重排链表 (25 分)给定一个单链表 L1→L2→⋯→Ln−1→Ln,请编写程序将链表重新排列为 Ln→L1→Ln−1→L2→⋯。例如:给定L为1→2→3→4→5→6,则输出应该为6→1→5→2→4→3。输入格式:每个输入包含1个测试用例。每个测试用例第1行给出第1个结点的地址和结点总个数,即正整数N (≤105)。结点的地址是5位非负整数,NULL地址用−1表示。接下来有N行,每行格式为:Address Data Next其中Address是结点地
2022-04-14 21:20:18
412
原创 L2-036 网红点打卡攻略 (25 分)
L2-036 网红点打卡攻略 (25 分)一个旅游景点,如果被带火了的话,就被称为“网红点”。大家来网红点游玩,俗称“打卡”。在各个网红点打卡的快(省)乐(钱)方法称为“攻略”。你的任务就是从一大堆攻略中,找出那个能在每个网红点打卡仅一次、并且路上花费最少的攻略。输入格式:首先第一行给出两个正整数:网红点的个数N(1<N≤200)和网红点之间通路的条数M。随后M行,每行给出有通路的两个网红点、以及这条路上的旅行花费(为正整数),格式为“网红点1 网红点2 费用”,其中网红点从 1 ...
2022-04-13 21:31:45
205
原创 L2-040 哲哲打游戏 (25 分)
L2-040 哲哲打游戏 (25 分)哲哲是一位硬核游戏玩家。最近一款名叫《达诺达诺》的新游戏刚刚上市,哲哲自然要快速攻略游戏,守护硬核游戏玩家的一切!为简化模型,我们不妨假设游戏有N个剧情点,通过游戏里不同的操作或选择可以从某个剧情点去往另外一个剧情点。此外,游戏还设置了一些存档,在某个剧情点可以将玩家的游戏进度保存在一个档位上,读取存档后可以回到剧情点,重新进行操作或者选择,到达不同的剧情点。为了追踪硬核游戏玩家哲哲的攻略进度,你打算写一个程序来完成这个工作。假设你已经知道了游戏的全部剧..
2022-04-12 21:36:27
111
原创 L2-037 包装机 (25 分)
L2-037 包装机 (25 分)一种自动包装机的结构如图 1 所示。首先机器中有N条轨道,放置了一些物品。轨道下面有一个筐。当某条轨道的按钮被按下时,活塞向左推动,将轨道尽头的一件物品推落筐中。当 0 号按钮被按下时,机械手将抓取筐顶部的一件物品,放到流水线上。图 2 显示了顺序按下按钮 3、2、3、0、1、2、0 后包装机的状态。图1 自动包装机的结构图 2 顺序按下按钮 3、2、3、0、1、2、0 后包装机的状态一种特殊情况是,因为筐的容量是有限的,当筐已经满了,但仍然有某..
2022-04-12 20:27:04
158
原创 L2-039 清点代码库 (25 分)
题目描述:上图转自新浪微博:“阿里代码库有几亿行代码,但其中有很多功能重复的代码,比如单单快排就被重写了几百遍。请设计一个程序,能够将代码库中所有功能重复的代码找出。各位大佬有啥想法,我当时就懵了,然后就挂了。。。”这里我们把问题简化一下:首先假设两个功能模块如果接受同样的输入,总是给出同样的输出,则它们就是功能重复的;其次我们把每个模块的输出都简化为一个整数(在int范围内)。于是我们可以设计一系列输入,检查所有功能模块的对应输出,从而查出功能重复的代码。你的任务就是设计并实现这个简化...
2022-04-12 19:48:44
218
原创 ccpc网络赛补题
1001Cut The WireTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 10125Accepted Submission(s): 2502Problem DescriptionIn the country ofInfinity, there is a strange road. This road onl...
2021-08-29 17:04:48
453
原创 Codeforces Round #741 (Div. 2)
A. The Miracle and the Sleepertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two integersllandrr,l≤rl≤r. Find the largest possible value ofamodbamodbover all pairs...
2021-08-27 16:06:25
358
原创 Codeforces Round #739 (Div. 3)
A. Dislike of Threestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp doesn't like integers that are divisible by33or end with the digit33in their decimal representation. Int...
2021-08-19 13:18:54
673
原创 3种简单排序
1、简单选择排序 简单选择排序是最简单直观的一种算法,基本思想为每一趟从待排序的数据元素中选择最小(或最大)的一个元素作为首元素,直到所有元素排完为止,简单选择排序是不稳定排序。 在算法实现时,每一趟确定最小元素的时候会通过不断地比较交换来使得首位置为当前最小,交换是个比较耗时的操作。其实我们很容易发现,在还未完全确定当前最小元素之前,这些交换都是无意义的。 我们可以通过设置一个变量min,每一次比较仅存储较小元素的数组下标,当轮循环结束之后,那这个变量存储的就是当前最小元素的下标,...
2021-08-08 11:24:56
4345
原创 xay loves or
Description xay loves or. He gives you x and s, you need to calculate how many positive integer y satisfy x or y = s. Input The first line contains two positive integers x and s . It’s guaranteed that 1 ≤ x, s < 2 31 . Output Print the number of y satis
2021-08-07 20:24:04
164
1
原创 VC Is All You Need
VC Is All You NeedTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 2033Accepted Submission(s): 845Problem DescriptionThree points example.Four points example.In this pictu...
2021-08-04 10:34:15
130
原创 Holding Two
Given n, m, construct a matrix A of size n × m, whose entries are all either 0 or 1, and no three distinct entries Ai1,j1 , Ai2,j2 , Ai3,j3 satisfying that Ai1,j1 = Ai2,j2 = Ai3,j3 , −1 ≤ i1 − i2 = i2 − i3 ≤ 1, −1 ≤ j1 − j2 = j2 − j3 ≤ 1. If multiple solut
2021-08-01 09:41:55
123
原创 LCS2021牛客暑期多校训练营4
链接:https://ac.nowcoder.com/acm/contest/11255/C来源:牛客网题目描述Let LCS(s1,s2)LCS(s_1,s_2)LCS(s1,s2) denote the length of the longest common subsequence (not necessary continuity) of string s1s_1s1 and string s2s_2s2.Now give you four integers a,b,c..
2021-07-26 20:44:15
136
原创 Just a joke
链接:https://ac.nowcoder.com/acm/contest/11255/F来源:牛客网题目描述Alice and Bob are playing a game.At the beginning, there is an undirected graph GGG with nnn nodes.Alice and Bob take turns to operate, Alice will play first. The player who can't operate wil.
2021-07-26 20:21:07
163
原创 Math 2021牛客暑期多校训练营 3
链接:https://ac.nowcoder.com/acm/contest/11254/E来源:牛客网题目描述Given n, count the number of pairs of positive integers (x, y), such that xy+1∣x2+y2,1≤x≤y≤nxy+1|x^2+y^2, 1\le x\le y \le nxy+1∣x2+y2,1≤x≤y≤n.There're t test cases in total.输入描述:First lin.
2021-07-25 15:49:29
214
1
原创 计数三角形
链接:https://ac.nowcoder.com/acm/contest/11254/J来源:牛客网题目描述古德亚特发现了一个没有方向的完整图形与n个顶点。图形的每个边缘都漆成黑色或白色。他想让你帮他找到三角形的数量(a,b,c)(一个<b<c),这样(a,b),(b,c),(c,a)之间的边缘有相同的颜色。为了避免输入比例过大,我们使用以下代码生成图表中的边缘。<span style="color:#333333">namespaceGenHelp..
2021-07-25 11:16:01
191
1
原创 Codeforces Round #734 (Div. 3)
A. Polycarp and Coinstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp must payexactlynnburles at the checkout. He has coins of two nominal values:11burle and22burles. Pol...
2021-07-24 09:57:52
317
2
原创 Girlfriend
链接:https://ac.nowcoder.com/acm/contest/11253/F来源:牛客网题目描述ZYTand ZFeTare great PUAs and both have two girlfriends,but they never think that their girlfriends could be so great at magic.One day, whenZYTandZFeTwerebusy training PU skills,they...
2021-07-23 10:41:25
208
1
原创 I love 114514
I love 114514Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1410Accepted Submission(s): 1098Problem DescriptionMr.I loves 114514 very much.Now Mr.I has a string, if "114514" is a substr...
2021-07-23 09:31:57
338
2
原创 I love string
I love stringTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 2070Accepted Submission(s): 965Problem DescriptionMr X likes to play string games.Mr X has an operation sequence. This oper...
2021-07-23 09:26:48
255
2
原创 I love cube
I love cubeTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 2805Accepted Submission(s): 770Problem DescriptionGive you a cube with a side length of n-1. Find the number of equilateral tr...
2021-07-22 21:19:27
171
3
原创 Minimum spanning tree
Problem DescriptionGiven n-1 points, numbered from 2 to n, the edge weight between the two points a and b is lcm(a, b). Please find the minimum spanning tree formed by them.A minimum spanning tree is a subset of the edges of a connected, edge-weighted u
2021-07-20 20:05:26
238
1
原创 Mod, Or and Everything
Problem DescriptionYou are given an integern.You are required to calculate (n mod 1) or (n mod 2) or ... or (n mod (n - 1)) or (n mod n).The "or" operation means "bitwise OR".InputThe first line contains an integerT(1≤T≤5000)representing the numb..
2021-07-20 19:59:09
288
1
原创 Er Ba Game
链接:https://ac.nowcoder.com/acm/contest/11253/D来源:牛客网题目描述Er Ba Game is a popular card game in China's Province Zhejiang.In this problem, the game involves two players and 36 cards - 2,3,⋯ ,102,3,\cdots, 102,3,⋯,10, each withfour.In the game each p..
2021-07-20 10:39:50
107
原创 Draw Grids
链接:https://ac.nowcoder.com/acm/contest/11253/C来源:牛客网题目描述ZYT and LBC decided to play a game.They will alternately do the following operation. Pick 4 integersa,b,c,d(1≤a,c≤na,b,c,d(1\leq a,c \leq na,b,c,d(1≤a,c≤nand 1≤b,d≤m)\ 1\leq b,d \leq ...
2021-07-20 10:38:24
163
原创 92. 递归实现指数型枚举
从1∼n1∼n这nn个整数中随机选取任意多个,输出所有可能的选择方案。输入格式输入一个整数nn。输出格式每行输出一种方案。同一行内的数必须升序排列,相邻两个数用恰好11个空格隔开。对于没有选任何数的方案,输出空行。本题有自定义校验器(SPJ),各行(不同方案)之间的顺序任意。数据范围1≤n≤151≤n≤15输入样例:3输出样例:322 311 31 21 2 3假如有1 2 5那么i=10011i&(i...
2021-07-20 10:31:07
91
原创 3773. 兔子跳
一只兔子位于二维平面的原点(0,0)(0,0)处,它想通过一系列的跳跃,跳到点(x,0)(x,0)处。给定一个长度为nn的数组a1,a2,…,ana1,a2,…,an。兔子能从一个点跳到另一个点,当且仅当两点之间的距离等于上述数组中的某个元素的值。请问,兔子从(0,0)(0,0)到(x,0)(x,0)最少需要跳几次?注意,兔子可以跳到非整数坐标的点上。例如,当x=4x=4,a={1,3}a={1,3}时,(0,0)→(1,0)→(4,0)(0,0)→(1,0)→...
2021-07-19 20:18:05
149
2
原创 Game of Swapping Numbers
链接:https://ac.nowcoder.com/acm/contest/11166/G来源:牛客网题目描述Given two arrays A, B with length N, you should perform exactly K operations in array A.For each operation, choose 2 elementsAi,Aj(1≤i<j≤N)A_i, A_j(1 \leq i < j \leq N)Ai,Aj(1≤i<j≤..
2021-07-19 09:53:23
153
原创 B. Putting Platestime limit per test
To celebrate your birthday you have prepared a festive table! Now you want to seat as many guests as possible.The table can be represented as a rectangle with heighthhand widthww, divided intoh×wh×wcells. Let(i,j)(i,j)denote the cell in theii-t...
2021-07-18 15:19:48
362
原创 A. Binary Decimal
A. Binary Decimaltime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputLet's call a number abinary decimalif it's a positive integer and all digits in its decimal notation are either00or...
2021-07-18 15:15:04
463
原创 2021牛客暑期多校训练营1Determine the Photo Position
链接:https://ac.nowcoder.com/acm/contest/11166/D来源:牛客网题目描述You have taken the graduation picture of graduates. The picture could be regarded as a matrix A of n×nn \times nn×n, each element in A is 0 or 1, representing a blank background or a student, r.
2021-07-17 21:18:45
132
原创 2021牛客暑期多校训练营1Find 3-friendly Integers
链接:https://ac.nowcoder.com/acm/contest/11166/F来源:牛客网题目描述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 333.For .
2021-07-17 21:15:45
238
原创 2021牛客暑期多校训练营1Ball Dropping
链接:https://ac.nowcoder.com/acm/contest/11166/B来源:牛客网题目描述A standard sphere ball is falling in the air, and the center of the sphere is exactly on the centerline of an empty isosceles trapezoidal. The trapezoid is hanging horizontally under the sphere.
2021-07-17 21:06:43
163
原创 3771. 选取石子
3771. 选取石子给定nn个石子,编号为1∼n1∼n。其中第ii个石子的价值为aiai。你需要从中任意挑选若干个石子,并将挑选好的石子按照编号从小到大的顺序排成一排。选中的石子在排好序后需要满足,对于任意两个相邻的石子(不妨设它们的编号为x,yx,y),x−y=ax−ayx−y=ax−ay均成立。例如,当有n=8n=8个石子,石子价值分别为[3,4,4,6,6,7,8,9][3,4,4,6,6,7,8,9]时,一些合理的选择方案如下:选择1,2,41,2,...
2021-07-17 20:47:05
138
原创 3770. 最小消耗
3770. 最小消耗有n个怪兽等待你去消灭。怪兽共分为两种形态,不妨用0和1来表示。消灭一个0形态的怪兽需要耗费的法力值为a。消灭一个1形态的怪兽需要耗费的法力值为b。你还可以使用改造魔法将0形态怪兽改造为1形态或将1形态怪兽改造为0形态。改造一个怪兽需要耗费的法力值为c。请问,将怪兽全部消灭最少需要耗费多少法力值。输入格式第一行包含整数TT,表示共有TT组测试数据。每组数据第一行包含四个整数n,a,b,cn,a,b,c。...
2021-07-17 20:43:33
153
原创 Codeforces Round #730 (Div. 2)
A. Exciting BetsInputThe first line of input contains a single integertt(1≤t≤5⋅1031≤t≤5⋅103) — the number of test cases.The first and the only line of each test case contains two integersaaandbb(0≤a,b≤10180≤a,b≤1018).OutputFor each test cas...
2021-07-08 20:11:28
93
原创 3761. 唯一最小数
3761. 唯一最小数给定一个长度为nn的整数数组a1,a2,…,ana1,a2,…,an。请你找到数组中只出现过一次的数当中最小的那个数。输出找到的数的索引编号。a1a1的索引编号为11,a2a2的索引编号为22,…,anan的索引编号为nn。输入格式第一行包含整数TT,表示共有TT组测试数据。每组数据第一行包含整数nn。第二行包含nn个整数a1,a2,…,ana1,a2,…,an。输出格式每组数据输出一行结果,即满足条件的数的索引编...
2021-07-08 19:37:22
545
原创 3636. 数组延伸
给定一个初始长度为nn的数组aa以及一个整数xx。我们现在要对数组aa进行延伸,具体方法如下:我们从数组中的第一个元素开始,逐个遍历数组中的每个元素。当遍历到数组中的元素qq时,如果qq能够被xx整除,则在数组的末尾添加xx个整数qxqx,并开始遍历下一个元素。否则,停止遍历,数组延伸结束。注意,后面新增的元素也要被考虑在内,加以处理和判断。请计算,在数组延伸结束后,数组中所有元素的和。输入格式第一行包含整数TT,表示共有TT组测试数据。...
2021-06-07 20:21:41
219
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人