自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Dejavu的博客

若有若似无,felling dejavu

  • 博客(156)
  • 收藏
  • 关注

原创 实验 2 :Bomb Lab

炸弹 1首先查看炸弹 111 的代码部分,发现是由 phase_1 函数来运行炸弹对 phase_1 函数使用 gdb 反汇编:disassemble phase_1得到 phase_1 函数的汇编代码发现该函数通过调用 strings_not_equal 函数后进行判断,接着进行反汇编:disassemble strings_not_equal查看代码后,发现这个函数是判断两个字符串是否相同,在这个函数的位置打上断点,并运行程序,任意输入字符串:break strings_not_

2022-05-04 11:38:40 316

原创 实验 1 :Data Lab

bitXor(x, y)使用~和&实现异或操作,返回x⊕yx \oplus yx⊕yint bitXor(int x, int y) { return ~(~x & ~y) & ~(x & y);}根据异或的运算规则,我们只需要将不同时为0的位和不同时为1做与操作即可。tmin()返回最小的整数补码...

2022-04-30 08:02:14 1130

原创 2020ICPC·小米 网络选拔赛热身赛

B题意描述思路对于每个数字,我们求出它的贡献。以1,2,1,31,2,1,31,2,1,3为例。a[1]a[1]a[1]在[1,1],[1,2],[1,3],[1,4][1,1],[1,2],[1,3],[1,4][1,1],[1,2],[1,3],[1,4]中出现,且出现了444次,贡献为1∗41*41∗4;a[2]a[2]a[2]在[2,2],[2,3],[2,4],[1,2],[1,3],[1,4][2,2],[2,3],[2,4],[1,2],[1,3],[1,4][2,2],[2,3

2020-11-06 19:02:59 302

原创 codeforces 1349A(数学)

题意描述思路题意要求求出gcd(lcm(ai,aj))∣i<jgcd(lcm(a_{i},a_{j})) | i<jgcd(lcm(ai​,aj​))∣i<j,由于lcm(ai,aj)=ai∗aj/gcd(ai,aj)lcm(a_{i},a_{j})=a_{i}*a_{j}/gcd(a_{i},a_{j})lcm(ai​,aj​)=ai​∗aj​/gcd(ai​,aj​),故得到式子gcd(ai∗aj/gcd(ai,aj))gcd(a_{i}*a_{j}/gcd(a_{i},a_{j

2020-10-15 19:54:43 169

原创 一些基础数论的知识和证明

算术基本定理N=pα1∗pα2∗...∗pαkN=p^{\alpha _{1}}*p^{\alpha _{2}}*...*p^{\alpha _{k}}N=pα1​∗pα2​∗...∗pαk​约数个数(α1+1)∗(α2+1)...∗(αk+1)(\alpha _{1}+1)*(\alpha _{2}+1)...*(\alpha _{k}+1)(α1​+1)∗(α2​+1)...∗(αk​+1)证明:已知N=pα1∗pα2∗...∗pαkN=p^{\alpha _{1}}*p^{\alpha _{

2020-10-07 17:38:26 616 4

原创 codeforces 1417C(思维)

题意描述思路使用一个vector数组来存储每个数字对应的下标,然后对111到nnn进行遍历,统计该数字相邻位置的最大距离,该距离即为子段长度为kkk时共用的数字。发现,长度为nnn的子段一定包含长度为n−1n-1n−1的子段,所以最后再遍历一遍,使res[i]=min(res[i],res[i−1])res[i]=min(res[i],res[i-1])res[i]=min(res[i],res[i−1])。AC代码#include<bits/stdc++.h>#define x f

2020-09-28 11:45:28 238

原创 codeforces 1420C1

题意描述思路我们定义dp[i[[0]dp[i[[0]dp[i[[0]为选择偶数的最大和,即最后一步是加法的最大和;dp[i][1]dp[i][1]dp[i][1]为选择奇数的最大和,即最后一步是减法的最大和。得出转移方程:dp[i][0]=max(dp[i−1][0],dp[i−1][1]+a[i])dp[i][0]=max(dp[i-1][0],dp[i-1][1]+a[i])dp[i][0]=max(dp[i−1][0],dp[i−1][1]+a[i])dp[i][1]=max(dp[i−1]

2020-09-27 17:41:41 198

原创 codeforces 1335E1+E2(思维)

题意描述思路+代码easy版本:我们只需要枚举[1,i],[i+1,j],[j+1,n][1,i],[i+1,j],[j+1,n][1,i],[i+1,j],[j+1,n]三个区间即可,设lenlrlenlrlenlr为第一个和第三个区间中出现最多的数字的次数,lenmidlenmidlenmid为第二个区间中出现最多数字的次数,则ans=max(ans,lenlr∗2+lenmid)ans=max(ans,lenlr*2+lenmid)ans=max(ans,lenlr∗2+lenmid)。我们可

2020-09-25 22:11:04 172

原创 codeforces 455A(dp)

题意描述Alex doesn’t like boredom. That’s why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.Given a sequence a consisting of n integers. The player can make several steps. In a single st

2020-09-24 08:19:14 201

原创 codeforces 1374E1(贪心+优先队列)

题意描述Easy and hard versions are actually different problems, so read statements of both problems completely and carefully.Summer vacation has started so Alice and Bob want to play and joy, but… Their mom doesn’t think so. She says that they have to read s

2020-09-22 20:04:03 149

原创 codeforces 1213D2(贪心+思维)

题意可以对每个数进行除2的操作,求最少需要操作多少次,使得数组中有k个相同的数思路题目中说答案始终存在,因为每个数都可以变成0,但很明显,让数字变成0的情况是不存在的,每个数字不停的除2肯定可以变成1,如果变成0,肯定不是最优解。我们可以使用一个cntcntcnt数组来记录每个数字出现的次数,使用tottottot数组来记录变成该数需要的次数,因为数据范围最大是2∗1052*10^52∗105,每个数字除2不超过20次就可以变成1,我们遍历一遍数组即可得到答案。AC代码#include<bi

2020-09-19 08:17:33 181

原创 codeforces 1203D2(贪心)

题意描述t是s的子串,求能够删除的最大区间,使得t仍是s的子串思路我们可以从左向右求出t的第i个字母在哪个位置 1=<i<=t1=<i<=t1=<i<=t,然后再同理从右向左求出right数组。最后遍历一遍,取right和left对应字母之间的最大值即可。AC代码#include<bits/stdc++.h>#define x first#define y second#define PB push_back#define mst(x,a)

2020-09-18 17:54:30 101

原创 codeforces 1283D(BFS)

题意描述有n个人,要求找到m个圣诞树,使n个人到m个圣诞树之间的距离之和最小思路使用bfs来做,贪心的考虑,我们先找与n个点距离为1的圣诞树,然后再找距离为2的圣诞树,依次类推。AC代码#include<bits/stdc++.h>#define x first#define y second#define PB push_back#define mst(x,a) memset(x,a,sizeof(x))#define all(a) begin(a),end(a)#def

2020-09-17 08:12:11 182

原创 codeforces 1328D(思维)

题意描述The round carousel consists of n figures of animals. Figures are numbered from 1 to n in order of the carousel moving. Thus, after the n-th figure the figure with the number 1 follows. Each figure has its own type — the type of the animal correspondin

2020-09-16 08:09:19 145

原创 codeforces 1311D(暴力)

题意描述You are given three integers a≤b≤c.In one move, you can add +1 or −1 to any of these integers (i.e. increase or decrease any number by one). You can perform such operation any (possibly, zero) number of times, you can even perform this operation seve

2020-09-15 21:47:28 115

原创 codeforces 1367D(思维)

题意描述Polycarp wrote on the board a string s containing only lowercase Latin letters (‘a’-‘z’). This string is known for you and given in the input.After that, he erased some letters from the string s, and he rewrote the remaining letters in any order. As

2020-09-15 20:47:57 127

原创 codeforces1294D(思维+暴力)

题意描述Recall that MEX of an array is a minimum non-negative integer that does not belong to the array. Examples:for the array [0,0,1,0,2] MEX equals to 3 because numbers 0,1 and 2 are presented in the array and 3 is the minimum non-negative integer not pre

2020-09-15 16:04:19 145

原创 codeforces1385D (递归+分治)

题意描述You are given a string s[1…n] consisting of lowercase Latin letters. It is guaranteed that n=2k for some integer k≥0.The string s[1…n] is called c-good if at least one of the following three conditions is satisfied:The length of s is 1, and it consi

2020-09-14 16:15:10 229

原创 codeforces 1343D(差分数组)

题意描述You are given an array a consisting of n integers (it is guaranteed that n is even, i.e. divisible by 2). All ai does not exceed some integer k.Your task is to replace the minimum number of elements (replacement is the following operation: choose som

2020-09-14 15:58:25 192

原创 codeforces 1353D(优先队列)

题意描述You are given an array a of length n consisting of zeros. You perform n actions with this array: during the i-th action, the following sequence of operations appears:Choose the maximum by length subarray (continuous subsegment) consisting only of zer

2020-09-13 11:40:16 223

原创 codeforces 1296D(贪心)

题意描述有n个怪物,a和b轮流对怪物造成a和b伤害,有k次超能力,超能力可以跳过对方的回合,如果a击败了怪物,则a获得一分,反之亦然。求a能够获得的最大点数思路要想获得最大的点数,那么要最大限度的使用k次超能力。使怪物的血量对(a+b)(a+b)(a+b)求余,使怪物的血量在1~a+b之间,如果求余后为0,则使血量回滚到之前的状态。然后计算每个血量使用的k的次数,容易想到次数为⌈h/a⌉−1\left \lceil h/a \right \rceil-1⌈h/a⌉−1,最后排序后计算答案即可。AC代

2020-09-12 21:59:20 172

原创 codeforces 1256D(优先队列+贪心)

题意描述You are given a binary string of length n (i. e. a string consisting of n characters ‘0’ and ‘1’).In one move you can swap two adjacent characters of the string. What is the lexicographically minimum possible string you can obtain from the given one

2020-09-08 20:46:48 186

原创 codeforces 1216D(数学)

题意描述There were n types of swords in the theater basement which had been used during the plays. Moreover there were exactly x swords of each type. y people have broken into the theater basement and each of them has taken exactly z swords of some single typ

2020-09-08 16:07:45 193

原创 codeforces 1203D1(暴力)

题意描述给定两个字符串s和t,s中包含t的子串,求最大删除的区间的长度,使得t仍是s的子串思路由于数据范围很小,所以我们暴力枚举删除字符的左右边界,统计长度即可AC代码#include<bits/stdc++.h>#define x first#define y second#define PB push_back#define mst(x,a) memset(x,a,sizeof(x))#define all(a) begin(a),end(a)#define rep(x

2020-09-08 15:29:09 98

原创 codeforces 1405B(思维)

题意描述You’re given an array a of n integers, such that a1+a2+⋯+an=0.In one operation, you can choose two different indices i and j (1≤i,j≤n), decrement ai by one and increment aj by one. If i<j this operation is free, otherwise it costs one coin.How ma

2020-09-07 14:52:10 247

原创 codeforces 1234C(思维)

题意描述一个管道有6种类型,两种直管四种弯管,可以将管道任意旋转,给定t个询问,回答每次是否可以从(0,0)到哪(1,n)。思路通过观察可以发现,如果是直管的话,只能向右移动。如果是弯管的话,需要保证同一位置的另一排也是弯管,否则移动失败。AC代码#include<bits/stdc++.h>#define x first#define y second#define PB push_back#define mst(x,a) memset(x,a,sizeof(x))#def

2020-09-06 15:19:00 229

原创 codeforces 515C (数学)

题意描述定义F(x)为x的每一位的阶乘之积,求F(a)=F(x),使a尽可能的大思路通过观察可以发现4!=3!+2!+2!4!=3!+2!+2!4!=3!+2!+2!6!=5!+3!6!=5!+3!6!=5!+3!8!=7!+2!+2!+2!8!=7!+2!+2!+2!8!=7!+2!+2!+2!9!=7!+3!+3!+2!9!=7!+3!+3!+2!9!=7!+3!+3!+2!所以我们统计一下个数,然后sort一下输出即可AC代码#include<bits/stdc++.h&gt

2020-09-06 10:56:38 168

原创 codeforces1216C (矩形面积交)

题意描述给定一块白色矩形和两块黑色矩形和一块白色矩形,询问两块黑色矩形是否能够覆盖到白色矩形思路我们从面积的角度来考虑,要想完全覆盖,那么需要分别计算两个黑色矩形与白色矩形相交的面积,再减去两个黑色矩形相交的面积,最后判断计算所得的面积是否大于白色矩形的面积。AC代码#include<bits/stdc++.h>#define x first#define y second#define PB push_back#define mst(x,a) memset(x,a,sizeo

2020-09-06 08:47:01 146

原创 codeforces 1256C (贪心+构造)

题意描述There is a river of width n. The left bank of the river is cell 0 and the right bank is cell n+1 (more formally, the river can be represented as a sequence of n+2 cells numbered from 0 to n+1). There are also m wooden platforms on a river, the i-th pl

2020-09-05 17:46:12 257

原创 codeforces 1399D

题意描述You are given a binary string s consisting of n zeros and ones.Your task is to divide the given string into the minimum number of subsequences in such a way that each character of the string belongs to exactly one subsequence and each subsequence loo

2020-08-07 08:37:45 223

原创 codeforces1322A(括号匹配)

题意描述A bracketed sequence is called correct (regular) if by inserting “+” and “1” you can get a well-formed mathematical expression from it. For example, sequences “(())()”, “()” and “(()(()))” are correct, while “)(”, “(()” and “(()))(” are not.The teach

2020-08-03 20:51:39 155

原创 codeforces 1040B(思维)

题意描述有n个煎饼,每次可以反转会反转左右k个,求最小反转次数思路如果k为0的话,每个煎饼一定需要反转。如果nnn能够整除2∗k+12*k+12∗k+1的话,那么每次都加2∗k+12*k+12∗k+1一定不会重叠,否则的话,我们可以先对余数的情况进行输出,然后就转换成了整除的状态。AC代码#include<bits/stdc++.h>#define x first#define y second#define PB push_back#define mst(x,a) memse

2020-08-02 21:14:11 152

原创 codeforces 1005D(数学)

题意描述给定一个字符串s,询问有s最多能够分成几部分可以被3整除思路我们发现,如果连续三位的数都不能被3整除,那么这三位加起来一定可以被整除。所以我们遍历一遍即可。AC代码#include<bits/stdc++.h>#define x first#define y second#define PB push_back#define mst(x,a) memset(x,a,sizeof(x))#define all(a) begin(a),end(a)#define rep

2020-08-02 13:46:36 188

原创 codeforces 1364B(数学)

题意描述Given a permutation p of length n, find its subsequence s1, s2, …, sk of length at least 2 such that:|s1−s2|+|s2−s3|+…+|sk−1−sk| is as big as possible over all subsequences of p with length at least 2.Among all such subsequences, choose the one whos

2020-08-01 16:41:16 190

原创 codeforces 1366B(线段相交)

题意描述You are given an array consisting of n integers a1, a2, …, an. Initially ax=1, all other elements are equal to 0.You have to perform m operations. During the i-th operation, you choose two indices c and d such that li≤c,d≤ri, and swap ac and ad.Calc

2020-08-01 15:13:30 153

原创 codeforces 1373C (数学)

题意描述给定一段伪代码,求程序结束后res的值res = 0for init = 0 to inf cur = init ok = true for i = 1 to |s| res = res + 1 if s[i] == '+' cur = cur + 1 else cur = cur - 1 if cur < 0 ok = fals

2020-07-31 16:15:46 297

原创 HDOJ 2112(最短路)

题意描述经过锦囊相助,海东集团终于度过了危机,从此,HDU的发展就一直顺风顺水,到了2050年,集团已经相当规模了,据说进入了钱江肉丝经济开发区500强。这时候,XHD夫妇也退居了二线,并在风景秀美的诸暨市浬浦镇陶姚村买了个房子,开始安度晚年了。这样住了一段时间,徐总对当地的交通还是不太了解。有时很郁闷,想去一个地方又不知道应该乘什么公交车,在什么地方转车,在什么地方下车(其实徐总自己有车,却一定要与民同乐,这就是徐总的性格)。徐总经常会问蹩脚的英文问路:“Can you help me?”。看着他那

2020-07-29 16:10:30 147

原创 codeforces 1144D(思维)

题意描述You are given an array a consisting of n integers. You can perform the following operations arbitrary number of times (possibly, zero):Choose a pair of indices (i,j) such that |i−j|=1 (indices i and j are adjacent) and set ai:=ai+|ai−aj|;Choose a pa

2020-07-28 16:17:14 350

原创 codeforces 722C(带权并查集+反向思维)

题意描述You are given an array consisting of n non-negative integers a 1, a 2, …, a n.You are going to destroy integers in the array one by one. Thus, you are given the permutation of integers from 1 to n defining the order elements of the array are destroye

2020-07-28 15:01:37 263

原创 POJ 2493 (map)

题意描述给定有n个词的字典和m个句子,每个词语除首位和末位的字母可以任意移动,求能够构成m个句子的总共不同情况有多少思路由于每个词语的中间位置可以任意改变,所以我们对每个词语中间的位置进行排序,并用map来记录排序后的词语出现的次数。对于m个句子,由于有空格的存在,所以我们可以使用getline来读取一行并用istringstream来对空格进行分割。AC代码#include<iostream>#include<cstdio>#include<sstream&gt

2020-07-27 19:33:41 111

空空如也

空空如也

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

TA关注的人

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