自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

转载 区间dp(模板+优化)

模板memset(dp,0,sizeof(dp))//初始dp数组for(int len=2;len<=n;len++){//枚举区间长度 for(int i=1;i<n;++i){//枚举区间的起点 int j=i+len-1;//根据起点和长度得出终点 if(j>n) break;//符合条件的终点 for(int k=i;k<=j;++k)//枚举最优分割点 dp[i][j]=min(dp[i]

2021-02-07 14:45:05 6

原创 状压dp入门

状压dp入门什么是状态压缩dp?状态压缩dp就是把某些用dfs会超时的递归调用过多的题目转换成用数组中的一位数表示状态。我们知道在二进制下每一位上不是0就是1,这样就可以很好的表示事物的状态,是存在还是不存在,状态压缩就是把状态压缩到一位数内,这一位数操作时都用二进制操作。要学状态压缩dp首先要对二进制有所了解。我们下面来介绍一下二进制的相关知识。1.’&’符号,x&y,会将两个十进制数在二进制下进行与运算,然后返回其十进制下的值。例如3(11)&2(10)=2(10)。2

2021-02-06 12:52:25 5

转载 数位dp总结(模板+例题)(从入门到放弃)

转载自:https://blog.csdn.net/wust_zzwh/article/details/52100392数位dp模板:typedef long long ll;int a[20];ll dp[20][state];//不同题目状态不同ll dfs(int pos,/*state变量*/,bool lead/*前导零*/,bool limit/*数位上界变量*/)//不是每个题都要判断前导零{ //递归边界,既然是按位枚举,最低位是0,那么pos==-1说明这个数我枚举完了

2021-02-02 15:36:38 9

原创 Codeforces Round #698 (Div. 2)

A Nezzar and Colorful Balls题意: 有一串非递减数列,你要涂色,保证有相同颜色的数组都是严格递增的,问最少要几种颜色。思路: 直接找最多有几个相同的数就行了。#include<bits/stdc++.h>using namespace std;typedef long long ll;int a[1007];int main(){ int t; scanf("%d",&t); while(t--) { memset(a,0,sizeo

2021-01-29 11:31:10 23

原创 Codeforces Round #691 (Div. 2)

A. Red-Blue Shuffle题意: 有n张片,每张卡牌上有两个数字,一个在上面是红色一个在下面是蓝色,我们可以按任意顺序排卡牌,然后按照上面的数字顺序把数字组合出来,红色的大就是红色的赢,蓝色大就是蓝色赢。求出谁赢的概率大。思路: 实际上我们只需要看每张卡片上是红色大还是蓝色大,然后看是红色大的卡片数量多就是红色概率大,反之也成立。#include<bits/stdc++.h>using namespace std;typedef long long ll;char a[1

2021-01-28 11:35:42 10

原创 ACM-ICPC Shenyang Oniste 2018 Best ACMer Solves the Hardest Problem

ACM-ICPC Shenyang Oniste 2018 Best ACMer Solves the Hardest Problem思路: 用map或者二维数组存点,然后先预处理出每个点的属于哪个k值,存在vector pair中,最后根据操作直接找就行了。如果是用二维数组存点的话,还要用vector把存进去的点记录下来,然后清空,不然直接memset会超时。#include<bits/stdc++.h>using namespace std;typedef long long

2021-01-23 18:01:39 10

原创 ACM-ICPC 2017 Asia Urumqi Coins

ACM-ICPC 2017 Asia Urumqi Coins题意: 有n个硬币全部正面朝下,你有m次操作,每次操作选择k个硬币抛起来,问在最优策略下,你得到数量最多的朝上的硬币数量的期望。思路: 我一开始想到的是dfs,但是感觉不行,复杂度太高了,后来又想到用概率dp做,我们每一次抛起来,规定现在有几个正面,然后去推这一次抛完后有几个正面,,最后得到概率,乘上期望就好了。但是dp的时候要注意类讨论,有一种情况是我们剩下的反面硬币不足k个,就需要用到已经是正面的硬币,这时候dp就要减去被卷进来的本来已

2021-01-22 16:30:20 24

原创 ACM-ICPC 2017 Asia Nanning E - The Champion

ACM-ICPC 2017 Asia Nanning E - The Champion题意: 有r场对局,2^r个人,你在当中实力排在第k位,当一个强的人跟弱的人打的时候,强的人赢的概率是p。你可以自由安排大家对局,最后留下来的人是胜者,问怎么安排对局你自己的胜率最高,最高是多少,输出。思路: 我们很容易想到你只有多更比你弱的人打,你成为最终胜者的概率才会越高。所以最优的情况是你跟弱者打,强者内部打,弱者内部打。直到一方没有。但是有个问题就是当强者的人数时奇数时,你就需要判断两种情况,一种是强者赢了,一

2021-01-21 17:59:45 9

转载 线性基+线段树模板

t组数据,n个数的序列,q次查询,取l,r区间中的数,使得这些数异或后 或 (|)上k的最大值。#include <cstdio>#include <cstring>#include <cmath>#include <algorithm>using namespace std;typedef long long LL;struct tree{ LL l, r; LL d[70];}t[40010];LL a[10010],

2021-01-20 16:32:45 5

转载 2017 ACM 区域赛青岛站(现场赛) K Our Journey of Xian Ends

2017 ACM 区域赛青岛站(现场赛) K Our Journey of Xian EndsLife is a journey, and the road we travel has twists and turns, which sometimes lead us to unexpected places and unexpected people. Now our journey of Xian ends. To be carefully considered are the following q

2021-01-19 17:05:04 21

原创 2020年广东工业大学第十届文远知行杯新生程序设计竞赛(同步赛)(详细题解)

A 肥猪的钢琴床思路: 我比赛的时候是没做出来,没往dp想,后来赛后看大佬代码才知道正解。我们发现对于每个点来说,都有两种情况,一种是取1留0,一种是取0留1,这正好是吻合了dp的想法,还有一种极端情况是把前面的所有的1全部去掉。所以我们就获得了三个dp式子dp[i][0]=dp[i-1][0]+a[i]-‘0’;dp[i][1]=min(dp[i-1][1]+‘1’-a[i],dp[i-1][0]+‘1’-a[i]);dp[i][2]=min(dp[i-1][1]+a[i]-‘0’,dp[i-1]

2020-12-06 20:57:35 319 2

原创 Codeforces Round #687 (Div. 2, based on Technocup 2021 Elimination Round 2)——D XOR-gun(思维)

Codeforces Round #687 (Div. 2, based on Technocup 2021 Elimination Round 2)——D XOR-gun题意: 给你一个非递减数组,你可以把其中任意两个相邻的数进行异或,然后把新的数放入原来的位置。问最少要几步可以把这个数组变成无序的。思路: 我们发现,以二进制的每一位为分界线,当在同一段的数大于等于三个的时候,它必然是可以变成无序的,并且只要操作一次,就是把大的两个数异或。而当其他情况时,我们发现由于数据的限制a<=10^9,

2020-12-02 20:38:05 11

原创 Educational Codeforces Round 99 (Rated for Div. 2)(详细题意+思路,A-D题)

A. Strange FunctionsLet’s define a function f(x) (x is a positive integer) as follows: write all digits of the decimal representation of x backwards, then get rid of the leading zeroes. For example, f(321)=123, f(120)=21, f(1000000)=1, f(111)=111.Let’s d

2020-12-02 20:30:38 62

原创 Codeforces Round #687 (Div. 2, based on Technocup 2021 Elimination Round 2)(详细题意+思路 A-C题)

A. Prison BreakThere is a prison that can be represented as a rectangular matrix with n rows and m columns. Therefore, there are n⋅m prison cells. There are also n⋅m prisoners, one in each prison cell. Let’s denote the cell in the i-th row and the j-th co

2020-11-29 18:16:32 114

原创 武汉大学2020年新生程序设计竞赛(同步赛)——F 仓鼠的完美算术教室

武汉大学2020年新生程序设计竞赛(同步赛)——F 仓鼠的完美算术教室思路: 因为他让你求所有不重复的数,我们正常求就使10^12次复杂度,肯定会超时,这时我们考虑道用前缀和来求。那具体怎么用前缀和呢,我们发现,我们从前往后遍历,当遍历道2时,2的次方数,比如4,8……都会和2有重合的地方,我们只要找到有多少不重复的就行了。比如说n=10,m=20,那么我们就有2,4,8是有可能连续的,而且有三个,我们预先处理出来在这个m次的情况下连续1个到连续20个最多有可能有多少种情况,为什么我们只用算到20,因为2

2020-11-24 21:08:05 61

原创 Codeforces Round #685 (Div. 2)——D Circle Game(思维+模拟+对称博弈)

Codeforces Round #685 (Div. 2)——D Circle GameUtkarsh is forced to play yet another one of Ashish’s games. The game progresses turn by turn and as usual, Ashish moves first.Consider the 2D plane. There is a token which is initially at (0,0). In one move

2020-11-22 15:25:18 56 1

原创 北京信息科技大学第十二届程序设计竞赛暨ACM选拔赛(同步赛)题解

A 爱丽丝的人偶(一)思路: 先排小的,然后插空排大的就好了。#include<bits/stdc++.h>using namespace std;typedef long long ll;const ll maxn=0x3f3f3f3f;int a[1000007];int main(){ int n; cin>>n; int e; if(n%2==0){ e=n/2; }else{ e=n/2+1; } int cnt=1; for(

2020-11-21 18:20:18 1341 4

原创 Codeforces Round #683 (Div. 2, by Meet IT)——D. Catching Cheaters

Codeforces Round #683 (Div. 2, by Meet IT)——D. Catching CheatersYou are given two strings A and B representing essays of two students who are suspected cheaters. For any two strings C, D we define their similarity score S(C,D) as 4⋅LCS(C,D)−|C|−|D|, where

2020-11-16 18:35:40 29

原创 Codeforces Round #682 (Div. 2)——D. Powerful Ksenia

Codeforces Round #682 (Div. 2)——D. Powerful KseniaKsenia has an array a consisting of n positive integers a1,a2,…,an.In one operation she can do the following:choose three distinct indices i, j, k, and thenchange all of ai,aj,ak to ai⊕aj⊕ak simultaneou

2020-11-14 16:43:57 48

原创 Codeforces Round #682 (Div. 2)——C. Engineer Artem(思维)

Codeforces Round #682 (Div. 2)——C. Engineer ArtemArtem is building a new robot. He has a matrix a consisting of n rows and m columns. The cell located on the i-th row from the top and the j-th column from the left has a value ai,j written in it.If two ad

2020-11-14 16:39:57 38

原创 Hello 2020——B. New Year and Ascent Sequence

Hello 2020——B. New Year and Ascent SequenceA sequence a=[a1,a2,…,al] of length l has an ascent if there exists a pair of indices (i,j) such that 1≤i<j≤l and ai<aj. For example, the sequence [0,2,0,2,0] has an ascent because of the pair (1,4), but th

2020-11-12 17:01:51 14

原创 Hello 2020——G. Seollal

Hello 2020——G. SeollalRecall that the permutation is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice in the array) and [1,3,4] is also

2020-11-12 16:48:43 36

原创 Codeforces Round #611 (Div. 3)——F. DIY Garland

Codeforces Round #611 (Div. 3)——F. DIY GarlandPolycarp has decided to decorate his room because the New Year is soon. One of the main decorations that Polycarp will install is the garland he is going to solder himself.Simple garlands consisting of severa

2020-11-10 21:21:26 18

原创 Codeforces Round #678 (Div. 2)—— D. Bandit in a City(图论)

Codeforces Round #678 (Div. 2)—— D. Bandit in a CityBandits appeared in the city! One of them is trying to catch as many citizens as he can.The city consists of n squares connected by n−1 roads in such a way that it is possible to reach any square from a

2020-11-06 21:47:06 43

原创 Codeforces Round #681 (Div. 1, based on VK Cup 2019-2020 - Final)——B. Identify the Operations(思维+组合)

Codeforces Round #681 (Div. 1, based on VK Cup 2019-2020 - Final)——B. Identify the OperationsWe start with a permutation a1,a2,…,an and with an empty array b. We apply the following operation k times.On the i-th iteration, we select an index ti (1≤ti≤n−i

2020-11-06 20:21:36 14

原创 Codeforces Round #681 (Div. 2, based on VK Cup 2019-2020 - Final)——D. Extreme Subtraction

Codeforces Round #681 (Div. 2, based on VK Cup 2019-2020 - Final)——D. Extreme SubtractionYou are given an array a of n positive integers.You can use the following operation as many times as you like: select any integer 1≤k≤n and do one of two things:dec

2020-11-06 09:22:28 13

原创 Codeforces Round #607 (Div. 1)——C. Jeremy Bearimy

Codeforces Round #607 (Div. 1)——C. Jeremy BearimyWelcome! Everything is fine.You have arrived in The Medium Place, the place between The Good Place and The Bad Place. You are assigned a task that will either make people happier or torture them for eterni

2020-11-05 20:28:05 10

原创 Codeforces Round #607 (Div. 1)——A. Cut and Paste

Codeforces Round #607 (Div. 1)——A. Cut and PasteWe start with a string s consisting only of the digits 1, 2, or 3. The length of s is denoted by |s|. For each i from 1 to |s|, the i-th character of s is denoted by si.There is one cursor. The cursor’s loc

2020-11-05 16:37:41 5

原创 Codeforces Round #607 (Div. 1)-B. Beingawesomeism

Codeforces Round #607 (Div. 1)-B. BeingawesomeismYou are an all-powerful being and you have created a rectangular world. In fact, your world is so bland that it could be represented by a r×c grid. Each cell on the grid represents a country. Each country h

2020-11-05 16:30:01 9

原创 Codeforces Round #681 (Div. 2, based on VK Cup 2019-2020 - Final)——C. The Delivery Dilemma(枚举)

Codeforces Round #681 (Div. 2, based on VK Cup 2019-2020 - Final)——C. The Delivery DilemmaPetya is preparing for his birthday. He decided that there would be n different dishes on the dinner table, numbered from 1 to n. Since Petya doesn’t like to cook, h

2020-11-03 22:48:58 32

原创 Educational Codeforces Round 79 (Rated for Div. 2)-D. Santa‘s Bot(求逆元+简单概率)

Educational Codeforces Round 79 (Rated for Div. 2)-D. Santa’s BotSanta Claus has received letters from n different kids throughout this year. Of course, each kid wants to get some presents from Santa: in particular, the i-th kid asked Santa to give them o

2020-11-03 22:38:41 9

原创 Codeforces Round #676 (Div. 2)-D. Hexagons(模拟)

Codeforces Round #676 (Div. 2)-D. HexagonsLindsey Buckingham told Stevie Nicks “Go your own way”. Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.Consider a hexagonal tiling of the plane as on the pictu

2020-10-29 19:10:32 13

原创 Educational Codeforces Round 97 (Rated for Div. 2)-C Chef Monocarp(背包)

Educational Codeforces Round 97 (Rated for Div. 2)-C Chef MonocarpChef Monocarp has just put n dishes into an oven. He knows that the i-th dish has its optimal cooking time equal to ti minutes.At any positive integer minute T Monocarp can put no more th

2020-10-28 20:58:23 29

原创 数据结构与程序设计实践期末大作业(编一个小游戏)————笨鸟先飞(C语言)

笨鸟先飞小游戏编程教学对于这个游戏我做的比较粗糙,用一个圆球代替了小鸟,如果导致您觉得降低了逼格,请自行更改。在写本小游戏前请先自行安装EGE图形库。直接上代码,因为代码已经非常详细了。视频讲解://笨鸟先飞原创小游戏源代码 #include <graphics.h> #include<stdio.h>#include<stdlib.h>#include<windows.h>// 函数外全局变量定义int birdx,birdy;//小鸟

2020-10-28 20:24:50 206

原创 Educational Codeforces Round 97 (Rated for Div. 2)-B. Reverse Binary Strings

B. Reverse Binary Stringstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string s of even length n. String s is binary, in other words, consists only of 0’s and 1’s.String s has ex

2020-10-28 20:12:07 22

原创 cf1417-D. Make Them Equal

cf1417-D. Make Them EqualYou are given an array a consisting of n positive integers, numbered from 1 to n. You can perform the following operation no more than 3n times:choose three integers i, j and x (1≤i,j≤n; 0≤x≤109);assign ai:=ai−x⋅i, aj:=aj+x⋅i.A

2020-10-27 18:32:11 71

原创 cf1417-C. k-Amazing Numbers

cf1417-C. k-Amazing NumbersYou are given an array a consisting of n integers numbered from 1 to n.Let’s define the k-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length k (recall that a subse

2020-10-27 18:26:35 57

原创 cf1417-B. Two Arrays

B. Two ArraysRedDreamer has an array a consisting of n non-negative integers, and an unlucky integer T.Let’s denote the misfortune of array b having length m as f(b) — the number of pairs of integers (i,j) such that 1≤i<j≤m and bi+bj=T. RedDreamer has

2020-10-27 16:55:35 75

原创 浙江农林大学第十九届程序设计竞赛暨天梯赛选拔赛——I 来解方程吧

浙江农林大学第十九届程序设计竞赛暨天梯赛选拔赛-I 来解方程吧链接:https://ac.nowcoder.com/acm/contest/7872/I来源:牛客网题目描述想必大家对于解方程一定不陌生,但是如果方程的变量有很多,这个时候再去依靠人脑计算就显得非常的不切实际了。所以我们希望你可以设计一个程序来帮助我们计算方程式的解。输入描述:N (表示方程式的变量数)接下里输入一个 N * (N + 1)的矩阵 A表示对于每一行来说A[i][1] * X[1] + A[i][2] *

2020-10-24 20:51:17 43

原创 浙江农林大学第十九届程序设计竞赛暨天梯赛选拔赛-D 涛涛和策策的游戏(尼姆博弈)

浙江农林大学第十九届程序设计竞赛暨天梯赛选拔赛-D 涛涛和策策的游戏链接:https://ac.nowcoder.com/acm/contest/7872/D来源:牛客网题目描述涛涛和策策打码累了的时候会聚在一起van游戏。某一天他们又凑在一起玩游戏了,因为最近他们在学数学知识,所以就开始van博弈小游戏了。他们写下n个数字,从策策开始两个人轮流进行操作,每次操作只能选择一个大于1的数字x,选择x的一个大于1的因数y,让x变为x/y。谁先不能操作谁就输了。现在你需要判断出是哪个学长赢了游戏。

2020-10-24 19:00:30 64

空空如也

空空如也

空空如也

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

TA关注的人 TA的粉丝

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