自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 CF #734 (Div. 3)B2. Wonderful Coloring - 2

题目链接题目大意:用k种颜色给一个序列着色,且有以下要求1.序列中的每个元素要么是用k种颜色绘制的,要么是没有绘制的;2.每两个被涂成同一颜色的元素是不同的。没有两个相同颜色的值;3.让我们计算k种颜色中每一种颜色中绘制的元素的数量-所有计算的数字必须相等;在满足前三个条件的序列的所有着色中,该序列的着色元素总数最大。思路:用结构体存入序列及其下标,以序列大小排序。然后将数值 1~k 循环赋值给结构体b,并把结构体a存的下标直接存入结构体b。注意:这时可能不满足条件3。需要将部分赋值清零

2021-07-24 09:28:22 198

原创 最长非递减子序列(动态规划)

dd爱科学1.0题目:https://ac.nowcoder.com/acm/contest/11211/A大科学家dddd最近在研究转基因白菜,白菜的基因序列由一串大写英文字母构成,dddd经过严谨的推理证明发现,只有当白菜的基因序列呈按位非递减形式时,这株白菜的高附加值将达到最高,于是优秀的dddd开始着手修改白菜的基因序列,dddd每次修改基因序列的任意位需要的代价是11,dddd想知道,修改白菜的基因序列使其高附加值达到最高,所需要的最小代价的是多少。输入描述:第一行一个正整数n(1≤n≤1

2021-05-29 10:15:48 446

原创 欧拉函数(求互质个数)

Farey SequenceThe Farey Sequence Fn for any integer n with n >= 2 is the set of irreducible rational numbers a/b with 0 < a < b <= n and gcd(a,b) = 1 arranged in increasing order. The first few areF2 = {1/2}F3 = {1/3, 1/2, 2/3}F4 = {1/4, 1/

2021-05-13 10:34:22 373

原创 Toys(思维 暴力)

ToysCalculate the number of toys that land in each bin of a partitioned toy box.Mom and dad have a problem - their child John never puts his toys away when he is finished playing with them. They gave John a rectangular box to put his toys in, but John is

2021-04-30 20:41:16 307 1

原创 最大比例(蓝桥杯)

最大比例题目描述X星球的某个大奖赛设了M级奖励。每个级别的奖金是一个正整数。并且,相邻的两个级别间的比例是个固定值。也就是说:所有级别的奖金数构成了一个等比数列。比如:16,24,36,54其等比值为:3/2现在,我们随机调查了一些获奖者的奖金数。请你据此推算可能的最大的等比值。输入格式:第一行为数字N,表示接下的一行包含N个正整数第二行N个正整数Xi(Xi<1 000 000 000 000),用空格分开。每个整数表示调查到的某人的奖金数额要求输出:一个形如A/B的分数,要

2021-04-04 10:59:35 505 1

原创 K倍区间(蓝桥杯)

K倍区间题目描述给定一个长度为N的数列,A1, A2, … AN,如果其中一段连续的子序列Ai, Ai+1, … Aj(i <= j)之和是K的倍数,我们就称这个区间[i, j]是K倍区间。你能求出数列中总共有多少个K倍区间吗?输入第一行包含两个整数N和K。(1 <= N, K <= 100000)以下N行每行包含一个整数Ai。(1 <= Ai <= 100000)输出输出一个整数,代表K倍区间的数目。样例输入5 212345样例输出6思路:

2021-04-03 19:34:54 218

原创 Play on words (欧拉回路+并查集)

Play on wordsSome of the secret doors contain a very interesting word puzzle. The team of archaeologists has to solve it to open that doors. Because there is no other way to open the doors, the puzzle is very important for us.There is a large number of m

2021-03-27 10:18:29 157

原创 Fast Queries (莫队)

Fast QueriesGiven an array of N integers indexed from 1 to N, and q queries, each in the form i j, you have to find the number of distinct integers from index i to j (inclusive).InputInput starts with an integer T (≤ 5), denoting the number of test case

2021-03-17 21:00:55 107

原创 计算字符串距离(dp)

计算字符串距离对于两个不同的字符串,我们有一套操作方法来把他们变得相同,具体方法为:修改一个字符(如把“a”替换为“b”)删除一个字符(如把“traveling”变为“travelng”)比如对于“abcdefg”和“abcdef”两个字符串来说,我们认为可以通过增加/减少一个“g”的方式来达到目的。无论增加还是减少“g”,我们都仅仅需要一次操作。我们把这个操作所需要的次数定义为两个字符串的距离。给定任意两个字符串,写出一个算法来计算出他们的距离。Input第一行有一个整数n。表示测试数据的组

2021-03-13 14:44:48 304

原创 「SCOI2011」糖果(spfa)

幼儿园里有 n 个小朋友, lxhgww 老师现在想要给这些小朋友们分配糖果,要求每个小朋友都要分到糖果。但是小朋友们也有嫉妒心,总是会提出一些要求,比如小明不希望小红分到的糖果比他的多,于是在分配糖果的时候, lxhgww 需要满足小朋友们的 k个要求。幼儿园的糖果总是有限的, lxhgww 想知道他至少需要准备多少个糖果,才能使得每个小朋友都能够分到糖果,并且满足小朋友们所有的要求。输入格式输入的第一行是两个整数 n ,k 。接下来 k 行,表示这些点需要满足的关系,每行 3 个数字,x

2021-03-09 20:50:54 267

原创 Drying (二分)

DryingIt is very hard to wash and especially to dry clothes in winter. But Jane is a very smart girl. She is not afraid of this boring process. Jane has decided to use a radiator to make drying faster. But the radiator is small, so it can hold only one th

2021-02-28 20:43:43 151

原创 记忆化搜索

FatMouse and Cheese(记忆化搜索)FatMouse has stored some cheese in a city. The city can be considered as a square grid of dimension n: each grid location is labelled (p,q) where 0 <= p < n and 0 <= q < n. At each grid location Fatmouse has hid betw

2021-01-31 20:33:11 63

原创 博弈。

1.巴什博弈有一种有趣的游戏,玩法如下:游戏双方轮流取石子;每人每次取走若干颗石子(最少取 1颗,最多取 k颗);石子取光,则游戏结束;最后取石子的一方为胜。假如参与游戏的玩家都非常聪明,问最后谁会获胜?输入格式输入仅一行,两个整数 n 和 k。输出格式输出仅一行,一个整数,若先手获胜输出 ,后手获胜输出 。样例输入 23 3输出 1#include<stdio.h>int main(){ int t,m,n; scanf("%d",&t);

2021-01-24 18:14:47 286

原创 最小圈 找负环(spfa+二分)

题目描述样例 1输入4 51 2 52 3 53 1 52 4 34 1 3输出3.66666667样例 2输入2 21 2 -2.92 1 -3.1输出-3.00000000#include<stdio.h>#include<string.h>#define ep 1e-10 int n,m,flag,tot;int fre[10010],nxt[10010],son[10010],vis[10010];double w[10010]

2020-12-26 10:33:43 171

原创 Peaceful Rooks 找环+并查集

You are given a n×n chessboard. Rows and columns of the board are numbered from 1 to n. Cell (x,y) lies on the intersection of column number x and row number y.Rook is a chess piece, that can in one turn move any number of cells vertically or horizontally

2020-12-25 21:38:06 613

原创 Keywords Search AC

Keywords Search题目描述给定n个长度不超过50 的由小写英文字母组成的单词准备查询,以及一篇长为m 的文章,问:文中出现了多少个待查询的单词。多组数据。输入格式第一行一个整数 T,表示数据组数;对于每组数据,第一行一个整数 n,接下去 n行表示 n 个单词,最后一行输入一个字符串,表示文章。输出格式对于每组数据,输出一个数,表示文中出现了多少个待查询的单词。样例样例输入15shehesayshrheryasherhs样例输出3数据范围与提示对于全部数据

2020-11-15 19:44:28 68

原创 字典树 Phone List

Phone List题目描述给定 个长度不超过 的数字串,问其中是否存在两个数字串 ,使得 是 的前缀,多组数据。输入格式第一行一个整数 ,表示数据组数。对于每组数据,第一行一个数 ,接下来 行输入 个数字串。输出格式对于每组数据,若存在两个数字串 ,,使得 是 的前缀,则输出 NO ,否则输出 YES 。请注意此处结果与输出的对应关系!样例样例输入2391197625999911254265113123401234401234598346样例输出

2020-11-10 18:49:30 330 1

原创 kmp Radio Transmission

Radio Transmission题目描述给你一个字符串,它是由某个字符串不断自我连接形成的。但是这个字符串是不确定的,现在只想知道它的最短长度是多少。输入格式第一行给出字符串的长度 ,第二行给出一个字符串,全由小写字母组成。输出格式输出最短的长度。样例样例输入 18cabcabca样例输出 13样例说明对于样例,我们可以利用 abc 不断自我连接得到 abcabcabc,读入的 cabcabca 是它的子串。#include<stdio.h>#include&

2020-11-08 13:21:49 101

原创 哈希 子串查找

*子串查找题目描述这是一道模板题。给定一个字符串 A和B一个字符串 ,求 B 在A 中的出现次数。 A和B 中的字符均为英语大写字母或小写字母。A中不同位置出现的B 可重叠。输入格式输入共两行,分别是字符串 A 和字符串B 。输出格式输出一个整数,表示 B在 A 中的出现次数。样例样例输入zyzyzyzzyz样例输出3在这里插#include<stdio.h>#include<string.h>#include<iostream&gt

2020-11-08 12:57:32 174

原创 二分 Best cow fences

Best Cow Fences题目描述给定一个长度为n 的非负整数序列 A ,求一个平均数最大的,长度不小于 L 的子段。输入格式第一行用空格分隔的两个整数n 和 L;第二行为 n 个用空格隔开的非负整数,Ai表示 。输出格式输出一个整数,表示这个平均数的 1000 倍。不用四舍五入,直接输出。样例输入10 66 4 2 10 3 8 5 9 4 1样例输出6500【数据范围与提示】n≤10^5, 0≤Ai​≤2000。思路:用二分枚举平均值mid,每个牛的价值都减去mid

2020-11-01 22:43:46 156

原创 喷水装置.0

喷水装置长 L米,宽W 米的草坪里装有 n个浇灌喷头。每个喷头都装在草坪中心线上(离两边各 w/2米)。我们知道每个喷头的位置(离草坪中心线左端的距离),以及它能覆盖到的浇灌范围。请问:如果要同时浇灌整块草坪,最少需要打开多少个喷头?输入格式输入包含若干组测试数据。第一行一个整数 T表示数据组数;每组数据的第一行是整数 n、L 和W ;接下来的 行,每行包含两个整数,给出一个喷头的位置和浇灌半径(上面的示意图是样例输入第一组数据所描述的情况)。输出格式对每组测试数据输出一个数

2020-10-30 20:17:50 103

原创 蓝桥杯 矩形面积交

矩形面积交题目描述平面上有两个矩形,它们的边平行于直角坐标系的X轴或Y轴。对于每个矩形,我们给出它的一对相对顶点的坐标,请你编程算出两个矩形的交的面积。输入输入仅包含两行,每行描述一个矩形。在每行中,给出矩形的一对相对顶点的坐标,每个点的坐标都用两个绝对值不超过10^7的实数表示。输出输出仅包含一个实数,为交的面积,保留到小数后两位。样例输入1 1 3 32 2 4 4样例输出1.00原来想的可麻烦,要加各种判定条件,结果这样就ac了。。。在这#include<stdio.

2020-10-13 19:40:45 283

原创 蓝桥杯 方格填数

方格填数如下的10个格子填入0~9的数字。要求:连续的两个数字不能相邻。(左右、上下、对角都算相邻)一共有多少种可能的填数方案?请填写表示方案数目的整数。注意:你提交的应该是一个整数,不要填写任何多余的内容或说明性文字。全排列函数调用next_permutation(f,f+10)直接暴力在这里插入代#include<stdio.h>#include<math.h>#include<algorithm>using namespace std;in

2020-10-13 19:31:14 85

原创 蓝桥杯 凑算式

凑算式 B DEFA + — + — = 10C GHI(如果显示有问题,可以参见【图1.jpg】)这个算式中AI代表19的数字,不同的字母代表不同的数字。比如:6+8/3+952/714 就是一种解法,5+3/1+972/486 是另一种解法。这个算式一共有多少种解法?注意:你提交应该是个整数,不要填写任何多余的内容或说明性文字。...

2020-10-13 19:24:31 284

原创 数论 Goodnumbers

The only difference between easy and hard versions is the maximum value of n.You are given a positive integer number n. You really love good numbers so you want to find the smallest good number greater than or equal to n.The positive integer is called go

2020-09-27 19:51:09 173

原创 线段树 hate it

I Hate It.很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。这让很多学生很反感。不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。Input本题目包含多组测试,请处理到文件结束。在每个测试的第一行,有两个正整数 N 和 M ( 0<N<=200000,0<M<5000 ),分别代表学生的数目和操作的数目。学生ID编号分别从1编到N。第二行包含N个整数,代表

2020-09-27 19:22:35 2202

原创 Power Strings.0 KMP

Given two strings a and b we define ab to be their concatenation. For example, if a = “abc” and b = “def” then ab = “abcdef”. If we think of concatenation as multiplication, exponentiation by a non-negative integer is defined in the normal way: a^0 = “” (t

2020-08-09 15:14:50 95

原创 最长回文。马拉车。0

给出一个只由小写英文字符a,b,c…y,z组成的字符串S,求S中最长回文串的长度.回文就是正反读都是一样的字符串,如aba, abba等Input输入有多组case,不超过120组,每组输入为一行小写英文字符a,b,c…y,z组成的字符串S两组case之间由空行隔开(该空行不用处理)字符串长度len <= 110000Output每一行一个整数x,对应一组case,表示该组case的字符串中所包含的最长回文长度.Sample InputaaaaababSample Output

2020-08-09 13:32:39 73

原创 多重背包。0

急!灾区的食物依然短缺!为了挽救灾区同胞的生命,心系灾区同胞的你准备自己采购一些粮食支援灾区,现在假设你一共有资金n元,而市场有m种大米,每种大米都是袋装产品,其价格不等,并且只能整袋购买。请问:你用有限的资金最多能采购多少公斤粮食呢?Input输入数据首先包含一个正整数C,表示有C组测试用例,每组测试用例的第一行是两个整数n和m(1<=n<=100, 1<=m<=100),分别表示经费的金额和大米的种类,然后是m行数据,每行包含3个数p,h和c(1<=p<=20

2020-07-25 13:10:46 64

原创 A==B?(思维 坑人水题)

Give you two numbers A and B, if A is equal to B, you should print “YES”, or print “NO”.Inputeach test case contains two numbers A and B.Outputfor each case, if A is equal to B, you should print “YES”, or print “NO”.Sample Input1 22 23 34 3Sample

2020-07-25 11:58:09 152

原创 贪心 炒股

You can perfectly predict the price of a certain stock for the next N days. You would like to profit on this knowledge, but only want to transact one share of stock per day. That is, each day you will either buy one share, sell one share, or do nothing. In

2020-07-25 11:55:20 76

原创 搜索 Ice Cave

You play a computer game. Your character stands on some level of a multilevel ice cave. In order to move on forward, you need to descend one level lower and the only way to do this is to fall through the ice.The level of the cave where you are is a rectan

2020-07-25 11:53:45 51

原创 all in all

You have devised a new encryption technique which encodes a message by inserting between its characters randomly generated strings in a clever way. Because of pending patent issues we will not discuss in detail how the strings are generated and inserted in

2020-06-09 20:52:37 116

原创 最大连续子数和.0

给定K个整数的序列{ N1, N2, …, NK },其任意连续子序列可表示为{ Ni, Ni+1, …,Nj },其中 1 <= i <= j <= K。最大连续子序列是所有连续子序列中元素和最大的一个,例如给定序列{ -2, 11, -4, 13, -5, -2 },其最大连续子序列为{ 11, -4, 13 },最大和为20。在今年的数据结构考卷中,要求编写程序得到最大和,现在增加一个要求,即还需要输出该子序列的第一个和最后一个元素。Input测试输入包含若干测试用例,

2020-06-09 20:50:51 133

原创 数学。0

I was trying to solve problem ‘1234 - Harmonic Number’, I wrote the following codelong long H( int n ) {long long res = 0;for( int i = 1; i <= n; i++ )res = res + n / i;return res;}Yes, my error was that I was using the integer divisions only. Ho

2020-06-06 16:31:38 79

原创 Fence Repair (贪心 优先队列)

Farmer John wants to repair a small length of the fence around the pasture. He measures the fence and finds that he needs N (1 ≤ N ≤ 20,000) planks of wood, each having some integer length Li (1 ≤ Li ≤ 50,000) units. He then purchases a single long board j

2020-06-02 22:20:39 133

原创 Aladdin and the Flying Carpet.0

It’s said that Aladdin had to solve seven mysteries before getting the Magical Lamp which summons a powerful Genie. Here we are concerned about the first mystery.Aladdin was about to enter to a magical cave, led by the evil sorcerer who disguised himself

2020-05-30 19:01:39 104

原创 Leading and Trailing

You are given two integers: n and k, your task is to find the most significant three digits, and least significant three digits of nk.InputInput starts with an integer T (≤ 1000), denoting the number of test cases.Each case starts with a line containing

2020-05-30 15:02:14 109 1

原创 Palindrome

A palindrome is a symmetrical string, that is, a string read identically from left to right as well as from right to left. You are to write a program which, given a string, determines the minimal number of characters to be inserted into the string in order

2020-05-28 22:16:09 66

原创 约数

A number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, … shows the first 20 humble numbers.Now given a humble number, please write a program to calcul

2020-05-27 22:00:31 112

空空如也

空空如也

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

TA关注的人

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