题面戳这里 A. Diana and Liana 首先如果s>ks>ks>k一定无解,特判一下.那么我们考虑找恰好满足满足题目中的要求的区间[l,r][l,r][l,r],那么需要要删去的数一定是(l−1)%k+max((r−l+1)−k,0)(l-1)\%k+max((r-l+1)-k,0)(l−1)%k+max((r−l+1)−k,0).前面的表示要把[1,l−1][1,l-1][1,l−1]区间删成kkk的倍数,后面的表示要把这个区间删到kkk长度以内.判断这个值是否不大于能够删的…
The last stage of Football World Cup is played using the play-off system. There are n teams left in this stage, they are enumerated from 1 to n. Several rounds are held, in each round the remaining teams are sorted in the order of their ids, then the…
题意:有\(n\)栋房子,每栋房子都有自己的颜色\(c_i\),你每次可以对连续的长度为\(k\)的区间改变任何房子的颜色,问最少多少次可以使得所有房子颜色相同. 题解:因为只有\(100\)中颜色,所以我们可以直接枚举颜色,然后去遍历房子,如果房子颜色和当前枚举的不符,那么我们操作的次数就要++,并且跳到\(j+k+1\)栋房子继续. 代码: #include <bits/stdc++.h> #define ll long long #define fi first #define se s…
题意:有一张\(n\)x\(m\)的图,图中每个点都关押着罪犯,在坐标\((r,c)\)处有一个出口,每名罪犯每秒可以可以像上下最有移动一个单位或者不动,问所有罪犯能够逃离监狱的最少时间. 题解:直接算四个顶点到出口的值求个最大即可. 代码: #include <bits/stdc++.h> #define ll long long #define fi first #define se second #define pb push_back #define me memset #define…
B. Mike and Children time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike decided to teach programming to children in an elementary school. He knows that it is not an easy task to interest…