【暑训组队 #1】 Array‘s Hash 树状数组

Vasya has invented a new hash function of an array. It is calculated as follows. While the array has at least two elements, the first two elements, call them a1 and a2, are deleted, and the new element a2−a1 is inserted to the beginning of the array. When
分类: 其他 发布时间: 09-10 11:54 阅读次数: 0

【暑训组队 #1】 Bonuses on a Line 二分

There are n bonuses on a line: the i-th bonus is located at the point xi. All coordinates of all bonuses are distinct. You are located at the point with the coordinate 0. How many bonuses can you collect in t seconds, if you can pass the distance 1 in one
分类: 其他 发布时间: 09-10 11:54 阅读次数: 0

Codeforces Round #658 (Div. 2) A - C 超详解

A. Common Subsequence题意:找出一个最短序列,里面的元素在AB数组里都出现过,若没有则输出NO思路:Map一下A数组里的东西,B遇到一个就输出就行。B搞完都没有的话就说明没有了AC代码:#include<iostream>#include<string>#include<algorithm>#include<cstdio>#include<cstring>#include<cmath>#inclu
分类: 其他 发布时间: 09-10 11:54 阅读次数: 0

【Maratona de Programa¸c˜ao da SBC 2019 M】 Maratona Brasileira de Popcorn 二分答案

The “Maratona Brasileira de Popcorn” is a competition that takes place annually to find out whichteam is the most organized, prepared and well-trained in the art of eating popcorn. It is organized byBrazilian Society of Popcorn Eaters (SBCp, its acronym
分类: 其他 发布时间: 09-10 11:54 阅读次数: 0

【Maratona de Programa¸c˜ao da SBC 2019 A】Artwork 并查集 模拟

The Mona Dura is one of the most valuable artworks in Nlogonia Museum. The famous painting isdisplayed in a rectangular room of M by N meters. The room entrance is in a corner of it, while theMona is in the corner diagonally opposite to the entrance.To
分类: 其他 发布时间: 09-10 11:54 阅读次数: 0

【BAPC 2016】 C. Brexit BFS(拓扑排序)

A long time ago in a galaxy far, far away, there was a large interstellar trading union, consistingof many countries from all across the galaxy. Recently, one of the countries decided to leavethe union. As a result, other countries are thinking about lea
分类: 其他 发布时间: 09-10 11:54 阅读次数: 0

【BAPC 2016 J】 Programming Tutors 二分图 二分答案

You are the founder of the Bruce Arden ProgrammingCollective, which is a tutoring programme that matchesexperienced programmers with newbies to teach them.You have N students and N tutors, but now you haveto match them up. Since the students will have
分类: 其他 发布时间: 09-10 11:54 阅读次数: 0

【HDU 4268】Alice and Bob 贪心 set

Problem DescriptionAlice and Bob’s game never ends. Today, they introduce a new game. In this game, both of them have N different rectangular cards respectively. Alice wants to use his cards to cover Bob’s. The card A can cover the card B if the height of
分类: 其他 发布时间: 09-10 11:54 阅读次数: 0

【HDU 1003】 Max Sum 最大子串和 DP

Problem DescriptionGiven a sequence a[1],a[2],a[3]…a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in this sequence is 6 + (-1) + 5 + 4 = 14.InputThe first line of the input contains an integer
分类: 其他 发布时间: 09-10 11:54 阅读次数: 0

【HDU 1059】 Dividing 多重背包问题 DP

Problem DescriptionMarsha and Bill own a collection of marbles. They want to split the collection among themselves so that both receive an equal share of the marbles. This would be easy if all the marbles had the same value, because then they could just s
分类: 其他 发布时间: 09-10 11:54 阅读次数: 0

【HDU 1114】 Piggy-Bank 背包问题 DP

Before ACM can do anything, a budget must be prepared and the necessary financial support obtained. The main income for this action comes from Irreversibly Bound Money (IBM). The idea behind is simple. Whenever some ACM member has any small money, he takes
分类: 其他 发布时间: 09-10 11:54 阅读次数: 0

【HDU 1171】Big Event in HDU 多重背包巧妙优化 DP

Nowadays, we all know that Computer College is the biggest department in HDU. But, maybe you don’t know that Computer College had ever been split into Computer College and Software College in 2002.The splitting is absolutely a big event in HDU! At the sam
分类: 其他 发布时间: 09-10 11:54 阅读次数: 0

【LeetCode 871】最低加油次数 动态规划DP 详解

汽车从起点出发驶向目的地,该目的地位于出发位置东面 target 英里处。沿途有加油站,每个 station[i] 代表一个加油站,它位于出发位置东面 station[i][0] 英里处,并且有 station[i][1] 升汽油。假设汽车油箱的容量是无限的,其中最初有 startFuel 升燃料。它每行驶 1 英里就会用掉 1 升汽油。当汽车到达加油站时,它可能停下来加油,将所有汽油从加油站转移到汽车中。为了到达目的地,汽车所必要的最低加油次数是多少?如果无法到达目的地,则返回 -1 。注意:如
分类: 其他 发布时间: 09-10 11:54 阅读次数: 0

【CodeForces 1156C】 Match Points 二分答案

You are given a set of points x1, x2, …, xn on the number line.Two points i and j can be matched with each other if the following conditions hold:neither i nor j is matched with any other point;|xi−xj|≥z.What is the maximum number of pairs of points yo
分类: 其他 发布时间: 09-10 11:54 阅读次数: 0

【SCAU 15新生赛】18100 奇怪的光照植物 差分

18100 奇怪的光照植物该题有题解时间限制:500MS 代码长度限制:10KB提交次数:547 通过次数:64题型: 编程题 语言: G++;GCC;VCDescription一种光照植物,用光照射一天就长1厘米。现在将这种植物种在一条直线型的培养容器中,坐标从0到n-1,每一个整点位置种植一棵这种植物,即共n棵。开始的时候所有植物的高度都为0。实验过程中,进行了m组,每组选择对范围为[L,R]的植物进行光照a天,每组参数L、R、a由输入数据给出。当所有实验结束后,我们想知道所有
分类: 其他 发布时间: 09-10 11:54 阅读次数: 0

【AcWing 281】 硬币 多重背包问题

给定N种硬币,其中第 i 种硬币的面值为Ai,共有Ci个。从中选出若干个硬币,把面值相加,若结果为S,则称“面值S能被拼成”。求1~M之间能被拼成的面值有多少个。输入格式输入包含多组测试用例。每组测试用例第一行包含两个整数N和M。第二行包含2N个整数,分别表示A1,A2,…,AN和C1,C2,…,CN。当输入用例N=0,M=0时,表示输入终止,且该用例无需处理。输出格式每组用例输出一个结果,每个结果占一行。数据范围1≤N≤100,1≤M≤105,1≤Ai≤105,1≤Ci≤100
分类: 其他 发布时间: 09-10 11:54 阅读次数: 0

【AcWing 178】第K短路 A*算法

给定一张N个点(编号1,2…N),M条边的有向图,求从起点S到终点T的第K短路的长度,路径允许重复经过点或边。注意: 每条最短路中至少要包含一条边。输入格式第一行包含两个整数N和M。接下来M行,每行包含三个整数A,B和L,表示点A与点B之间存在有向边,且边长为L。最后一行包含三个整数S,T和K,分别表示起点S,终点T和第K短路。输出格式输出占一行,包含一个整数,表示第K短路的长度,如果第K短路不存在,则输出“-1”。数据范围1≤S,T≤N≤1000,0≤M≤105,1≤K≤1000,
分类: 其他 发布时间: 09-10 11:54 阅读次数: 0

【牛客多校 #7】 H Dividing 整数分块

链接:https://ac.nowcoder.com/acm/contest/5672/H来源:牛客网The following rules define a kind of integer tuple - the Legend Tuple:(1, k) is always a Legend Tuple, where k is an integer.if (n, k) is a Legend Tuple, (n + k, k) is also a Legend Tuple.if (n, k) is
分类: 其他 发布时间: 09-10 11:54 阅读次数: 0

【SCAU新生赛 9513】 防空洞 背包问题 DP

Description有一天,dragon123偷偷地拿锄头在学校里挖开了一个尘封已久的防空洞。他在这个防空洞里面找到许多贵重的东西:一些石头和一些液体。dragon123知道,只要他把这些石头和液体拿出去卖,那么就一定可以赚大钱。但是,他只有一个载重量为W的瓶子来装这些东西。防空洞里面有很多块石头,每块石头的重量为Wi,价值为Mi,但是石头不能够砸烂,否则就不值钱了。此外,洞里面很多种贵重的液体。对于某种液体,洞内存储了Wi重量,且这Wi重量液体的总价值为Mi。液体是可以部分放进瓶子里面的。也
分类: 其他 发布时间: 09-10 11:54 阅读次数: 0

【AcWing 198】 反素数 dfs 数论

对于任何正整数x,其约数的个数记作g(x),例如g(1)=1、g(6)=4。如果某个正整数x满足:对于任意的小于x的正整数 i,都有g(x)>g(i) ,则称x为反素数。例如,整数1,2,4,6等都是反素数。现在给定一个数N,请求出不超过N的最大的反素数。输入格式一个正整数N。输出格式一个整数,表示不超过N的最大反素数。数据范围1≤N≤2∗109输入样例:1000输出样例:840题意:如题思路:依照题意,不难得出x是【1,x】中约数个数最大的那个,而且其中没有个数相等的
分类: 其他 发布时间: 09-10 11:54 阅读次数: 0