自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Educational Codeforces Round 96 (Rated for Div. 2) E. String Reversal 树状数组

题意:将一个字符串只能通过相邻字符交换从而反转,问需要多少次数思路:我们从末尾开始,往前把字符交换,如果字符串里没有重复字母的话,这样就是最优秀的 , 相邻交换,求逆序对即可 ,但对于有重复字母,我们需要肯定将较前的字母先往前把字符交换,这样次数一定会更少,所有从后往前遍历,记录下标,这样保证前面的字符会首先取得,用栈也可以,然后选择好位置用树状数组求逆序对即可#include <bits/stdc++.h>using namespace std;const int N = 2.

2020-12-03 16:15:28 112

原创 Codeforces Round #672 (Div. 2) C1. Pokémon Army (easy version)

This is the easy version of the problem. The difference between the versions is that the easy version has no swap operations. You can make hacks only if all versions of the problem are solved.Pikachu is a cute and friendly pokémon living in the wild pikac

2020-11-26 22:27:34 134

原创 Codeforces Round #672 (Div. 2) B. Rock and Lever

Danik urgently needs rock and lever! Obviously, the easiest way to get these things is to ask Hermit Lizard for them.Hermit Lizard agreed to give Danik the lever. But to get a stone, Danik needs to solve the following task.You are given a positive intege

2020-11-26 22:20:51 134

原创 Codeforces Round #672 (Div. 2) A

Wheatley decided to try to make a test chamber. He made a nice test chamber, but there was only one detail absent — cubes.For completing the chamber Wheatley needs n cubes. i-th cube has a volume ai.Wheatley has to place cubes in such a way that they wou

2020-11-26 22:02:38 131

原创 Codeforces Round #671 (Div. 2) D2. Sage‘s Birthday (hard version)

outputstandard outputThis is the hard version of the problem. The difference between the versions is that in the easy version all prices ai are different. You can make hacks if and only if you solved both versions of the problem.Today is Sage’s birthday,

2020-11-25 23:28:13 103

原创 Codeforces Round #671 (Div. 2) C. Killjoy

outputstandard outputA new agent called Killjoy invented a virus COVID-2069 that infects accounts on Codeforces. Each account has a rating, described by an integer (it can possibly be negative or very large).Killjoy’s account is already infected and has

2020-11-25 23:22:27 95

原创 2020-09-28

洛谷图的遍历 P3916题目描述给出NN个点,MM条边的有向图,对于每个点vv,求A(v)A(v)表示从点vv出发,能到达的编号最大的点。输入格式第1 行,2 个整数N,MN,M。接下来MM行,每行2个整数U_i,V_iUi​,Vi​,表示边(U_i,V_i)(Ui​,Vi​)。点用1, 2,\cdots,N1,2,⋯,N编号。输出格式N 个整数A(1),A(2),\cdots,A(N)A(1),A(2),⋯,A(N)。输入输出样例输入 #1复制4 31 2.

2020-09-28 17:34:00 401

原创 Codeforces 667div3 D.Decrease the Sum of Digits

You are given a positive integer n. In one move, you can increase n by one (i.e. make n:=n+1). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of n be less than or equal to s.You have to answer t ind

2020-09-08 11:54:53 133

原创 CodeForces 667div3 C.Yet Another Array Restoration

We have a secret array. You don’t know this array and you have to restore it. However, you know some facts about this array:The array consists of n distinct positive (greater than 0) integers.The array contains two elements x and y (these elements are kn

2020-09-08 11:49:01 250

原创 Codeforces Round #661 (Div. 3) Binary String To Subsequences 队列

题意:给你一个01串 要求把他分成不同的子序列 并且子序列中不能有两个相同的数相邻 输出分成最少子序列的个数 并且 输出每个0或者1分别在哪个子序列思路:一开始看到这个题,就想到用栈或者队列来模拟这个过程,vector来存答案,但是栈无法得到最初未配对0或者1出现的位置,所以采用队列,我们开两个队列,一个用来存0的位置,一个用来存1的位置。1.当遇到0时,首先肯定先找有没1和他配对,如果队列1为空的话,说明这个0得属于新的一个序列,就往vector里存答案,如果有的话,往答案里存入队列1里队头序列的

2020-08-06 11:54:45 98

原创 Codeforces Round #640 (Div. 4)

A.题意:给出一个数n 把n拆成若干个除首位以外都是0的和思路:%一下 /一下就行#include <bits/stdc++.h>using namespace std;#define LL long long#define ULL unsigned long long#define mes(x,a) memset(x,a,sizeof(x));#define sca(a) scanf("%d",&a)#define lowbit(x) x & (-x)

2020-05-10 21:52:47 171

原创 FJUT 3729 dsc运电脑 二分+最短路

Dsc是个送货员,他所在的地方有n个城市,k条道路,在moxin下了电脑订单后,dsc需要从他老板所在的工厂(序号为1)运送电脑到达moxin的网吧(序号为n),dsc比较懒,所以他一天只运一次货,且从工厂到moxin网吧的时间需控制在t秒内,已知每台电脑重m 千克,途中经过许多个城市,城市之间可能会有道路,每条道路限重Mi kg(当载重量>限重则不允许通过),经过每条路需Ti秒时间(道路必...

2020-04-29 15:15:49 134

原创 HDU 4253 二分 + 最小生成树

题意:题意是给出n个点,m条边其中有的属于A有的属于B,要求构造最小生成树 并且 包含k条A的边 求最小花费思路:这题思路有点nb 我们二分一个权值给属于A公司的边加上 我们知道kruskal需要按照权值排序 那么属于A的边一定会靠后点 这样跑一遍kruskal 看看构造出来的是否满足有k条属于A的边 如果不满足那么权值下调 r = mid 否则 权值上调 l = mid 这样单调性就出来...

2020-04-29 14:44:50 154

原创 Codeforces Round #636 (Div. 3)

A.题意:计算是否存在x + 2x + 4x + … + = n思路:暴力计算 根据等比数列公式 x = n / (2^n -1) 暴力枚举分母 是否存在即可#include <bits/stdc++.h>using namespace std;int main(){ int t ; cin >> t; while(t--) ...

2020-04-23 17:02:16 98

原创 Codeforces Round #635 (Div. 2)

A.题意:给出四个数 a b c d 要求从 a到b b到c c到d 选三个数构造三角形思路:选b c c 就行 了 一定满足题意B.思路:贪心 一直使用第一种方法 然后在判断第二种方法能否将其杀死 记得特判单纯第二种方法就能杀死的情况 样例有给#include <bits/stdc++.h>using namespace std;#define LL long lo...

2020-04-19 00:14:02 131

原创 Codeforces Round #634 (Div. 3)

http://codeforces.com/contest/1335A.题意:给出一个数n 问有多少种方法构成n = a + b 并且 a > b思路:签到 /2就行 如果是偶数的话 还要-1 因为不能相等#include <bits/stdc++.h>using namespace std;#define LL long long#define mes(x,a...

2020-04-16 23:46:40 224 1

原创 牛客练习赛61

A.https://ac.nowcoder.com/acm/contest/5026/A题意:给你怪物和勇士 血量和攻击 问勇士能杀几个怪物思路:先计算勇士杀死怪物要几回合 如果勇士能一刀秒的话 就是无限个 否则计算杀死单个怪物勇士要掉多少血 根据总的计算就好了#include <bits/stdc++.h>using namespace std;#define LL...

2020-04-14 21:33:59 120

原创 Codeforces Round #622 (Div. 2) B、C

B. Different Rulestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputNikolay has only recently started in competitive programming, but already qu...

2020-04-10 00:35:06 112

原创 牛客OI周赛15-普及组 树状数组 + 离散化

题意:n在1e5 m在50以内 存在多少个m元组满足条件思路:从三元组的扩展 对于数组中的某一个点 对答案的贡献就是 左边小于他的数 x 右边大于他的数所以考虑构造m个树状数组来维护和查询#include <bits/stdc++.h>using namespace std;#define LL long long#define mes(x,a) memset(x...

2020-04-06 22:41:45 148

原创 Codeforces Round #623D. Recommendations并查集

D. Recommendationstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputVK news recommendation system daily selects interesting publications of one...

2020-04-02 23:55:56 163

原创 Codeforces Round #624 (Div. 3)D. Three Integers

D. Three Integerstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given three integers a≤b≤c.In one move, you can add +1 or −1 to any...

2020-03-31 20:49:40 124 1

原创 Codeforces Round #624 (Div. 3)

C. Perform the Combotime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou want to perform the combo on your opponent in one popular fighting ga...

2020-03-31 20:43:30 156

原创 Ozon Tech Challenge 2020 (Div.1 + Div.2, Rated, T-shirts + prizes!)

C. Kuroni and Impossible Calculationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTo become the king of Codeforces, Kuroni has to solve the ...

2020-03-30 21:31:12 503

原创 Codeforces Round #625 (Div. 2, based on Technocup 2020 Final Round)

A.A. Contest for Robotstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp is preparing the first programming contest for robots. There ...

2020-03-29 18:56:58 224

原创 牛客练习赛60补题

A.https://ac.nowcoder.com/acm/contest/4853/A思路:考虑位运算&的特性 只有两者都为1才会对答案有贡献 且 对答案贡献的值为 1 << k 其中k是当前1所在二进制下的位数 所以考虑预处理每一个位的1出现的次数 其中对每一位都会遍历n*n次 所以每一位对答案的贡献就是 a[i]a[i](1 << i) a[i]为当...

2020-03-29 13:43:06 82

原创 Codeforces Round #629 (Div. 3)

A. Divisibility Problemtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two positive integers a and b. In one move you can increa...

2020-03-28 01:09:41 115

原创 Educational Codeforces Round 84 (Rated for Div. 2)

A. Sum of Odd Integerstime limit per test:2 secondsmemory limit per test:256 megabytesinput:standard inputoutput:standard outputYou are given two integers nnand kk. Your task is to find if n...

2020-03-25 23:59:48 701

原创 牛客小白月赛23

https://ac.nowcoder.com/acm/contest/4784/BB.阶乘题意:给出一个正整数p 要你求一个最小的正整数n 使得 n的阶乘 为 p 的倍数思路:先要知道 n的阶乘要为p的倍数 则等价于 n的阶乘中包含所有p的素因子个数 如果n的阶乘都包含了 大于n的阶乘就更不用说了 所以我们先对p进行质因数分解 然后遍历所有因子判断是否符合条件 二分即可tip:用c...

2020-03-23 00:40:03 180

原创 Codeforces Global Round 7

A. Bad Ugly Numberstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a integer n (n>0). Find any integer s which satisfies thes...

2020-03-21 00:26:57 267

原创 Codeforces Round #628 (Div. 2)

A.A. EhAb AnD gCdtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a positive integer x. Find any such 2 positive integers a and ...

2020-03-19 13:17:35 186

原创 牛客练习赛59

A.题意:给你一个字符串s 问里面是否存在子序列 XiaoHuiHui 和 XiaoQiao思路:暴力分别找两个是否存在就行#include <bits/stdc++.h>using namespace std;#define LL long long#define pb(x) push_back(x)#define debug(x) cout<<"......

2020-03-16 22:12:54 125

原创 CodeCraft-20 (Div. 2) A、B、C

A. Grade Allocationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputn students are taking an exam. The highest possible score at this exam is m...

2020-03-06 01:04:34 154

原创 2020牛客寒假算法基础集训营5

A.题意:两个字符串 可以将其中一个字符串做以下操作 使两个字符串相等最小操作步数任意一个字母替换为另一个把最后一个字母删除在尾部添加一个字母思路:贪心就好 多余的直接删掉 不相同的再更改即可#include <iostream>#include <cstdio>#include <cstring>#include <cmath>...

2020-02-15 12:05:26 137

原创 2020牛客寒假算法基础集训营4

A.已知 gcd(a,b) 共递归了 n次,求所有可能的a,b中满足a>b>=0且a+b最小的一组的a与b之和。思路:枚举几个就发现是斐波那契数列 打个表就好了 而且这个n <= 80 很耐人寻味 斐波那契数列小于80的时候LL是存的下的#include <iostream>#include <cstdio>#include <cstri...

2020-02-13 22:07:17 111

原创 Codeforces Round #618 (Div. 2)

A.Guy-Manuel and Thomas have an array aa of nn integers [a1,a2,…,ana1,a2,…,an]. In one step they can add 11 to any element of the array. Formally, in one step they can choose any integer index ii (1≤...

2020-02-10 20:20:14 306

原创 2020牛客寒假算法基础集训营3

A.https://ac.nowcoder.com/acm/contest/3004/A题意:给定一个迷宫 迷宫上有R D B 三种字符分别代表 只能向右 下 右或者下均可 走 问走到迷宫n,m有多少种方法思路:经典的走格子dp问题 分情况来判别即可#include <iostream>#include <cstdio>#include <cstring&...

2020-02-09 21:38:56 94

原创 2020牛客寒假算法基础集训营2

A签到 不说了B链接:https://ac.nowcoder.com/acm/contest/3003/B来源:牛客网牛可乐 最喜爱的字符串是 \text{616}616。牛可乐得到了一个纯数字的字符串 \text{}SS,他想知道在可以任意打乱 \text{}SS 顺序的情况下,最多有多少个不同的子串为 \text{616}616 。​ 时它们被认为是不同的。输入描述:第一行,...

2020-02-06 22:52:16 267

原创 2020牛客寒假算法基础集训营1

有一天,kotori发现了一个和lovelive相似的游戏:bangdream。令她惊讶的是,这个游戏和lovelive居然是同一个公司出的!kotori经过一段时间的练习后已经变得非常触,每个音符 x%x% 的概率perfect,获得 分, (100 -x)%(100−x)% 概率great,获得 分。已知一首歌有 个音符。kotori想知道,不考虑连击加成的话,一首歌得分的期望是多少...

2020-02-06 18:12:41 438

原创 背包问题

背包问题是线性dp的一种特殊模型 其主要问题分为以下几种1.01背包问题对于每种物品的状态只有拿或者不拿两种状态有 N 件物品和一个容量是 V 的背包。每件物品只能使用一次。第 i 件物品的体积是 vi,价值是 wi。求解将哪些物品装入背包,可使这些物品的总体积不超过背包容量,且总价值最大。输出最大价值。#include <bits/stdc++.h>using na...

2020-02-06 12:43:51 174

原创 搜索整理

搜索分为两种 深度优先搜索 和 广度优先搜索 个人认为解决搜索问题的关键是 找到状态的转移 并且在有限的时间或者空间内找到正确的答案1.深度优先搜索dfs是以深度优先的方式 遍历二叉树 一条路走到黑 说白了就是瞎几把递归 一般数据量较小的时候 可以采用这种方法 最基础的问题就是全排列的生成#include <bits/stdc++.h>using namespace st...

2020-01-22 16:31:51 167

空空如也

空空如也

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

TA关注的人

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