A. Vasya and Book time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vasya is reading a e-book. The file of the book consists of nn pages, numbered from 11 to nn. The screen is currently disp…
传送门 https://www.cnblogs.com/violet-acmer/p/10035971.html 题意: 一本书有n页,每次只能翻 d 页,问从x页到y页需要翻动几次? 注意:往前翻最少翻到第1页,往后翻最多翻到n页. 题解: 一开始想找规律来着,emmmm,直接用广搜,当时竟然过了,第二天,加数据了,直接就TLE了. 然后,今天下午,mxl给我和lk讲了一下ta的做法,找的规律,啊啊啊,我竟然没想到. 规律: (1):如果abs(x-y)%d == 0,那么,那么直接输出abs…
C. Multi-Subject Competition time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A multi-subject competition is coming! The competition has mm different subjects participants can choose from.…
D. Maximum Diameter Graph time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Graph constructive problems are back! This time the graph you are asked to build should match the following proper…
B. Vova and Trophies time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vova has won nn trophies in different competitions. Each trophy is either golden or silver. The trophies are arranged i…
http://codeforces.com/contest/1082/problem/A WA数发,因为默认为x<y = = 分情况讨论,直达 or x->1->y  or  x->n->y  取最小值. #include<bits/stdc++.h> using namespace std; #define LL long long #define inf 0x3f3f3f3f #define mp make_pair #define pb push_back…
传送门:http://codeforces.com/contest/1082/problem/C C. Multi-Subject Competition time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A multi-subject competition is coming! The competition has mm …
传送门:http://codeforces.com/contest/1082/problem/B B. Vova and Trophies time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vova has won nn trophies in different competitions. Each trophy is eit…
E. Increasing Frequency 题目链接:https://codeforces.com/contest/1082/problem/E 题意: 给出n个数以及一个c,现在可以对一个区间上的数同时加上或减去一个值,问最后c的最多数量为多少. 题解: 这题挺有意思的,我们通过分析题目可以发现,对于每一个d,如果把[l,r]里面的d都变为c,则最后c的数量为cnt(c,1,l-1)+cnt(c,r+1,n)+cnt(d,l,r). 这个式子变化一下,有:cnt(c,1,n)+cnt(d,…
D. Maximum Diameter Graph 题目链接:https://codeforces.com/contest/1082/problem/D 题意: 给出n个点的最大入度数,要求添加边构成一个无环无向无重边的图,并且最大化图中的最短路径. 题解: 要求最短路径最大,我们会想到把每一个允许入度可以大于1的点先连起来,形成一个”链“,当前肯定满足条件,并且两端点的最短路径长度是所有情况中最大的. 然后对于入度为1的点,先尽量考虑放在链的两端,然后再在中间随便插入. 代码如下: 先附上自己…