既然补了就简单记录一下. 感觉还算有一点营养. 官方题解传送门:点我 A Commentary Boxes 对拆掉$n \mod m$个和新建$m - (n \mod m)$求个最小. #include <cstdio> #include <cstring> #include <algorithm> using namespace std; typedef long long ll; int main() { ll n, m, a, b, r; scanf("…
C. Bracket Sequences Concatenation Problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A bracket sequence is a string containing only characters "(" and ")". A regular…
E - Post Lamps 思路:一开始看错题,以为一个地方不能重复覆盖,我一想值这不是sb题吗,直接每个power check一下就好....复杂度nlogn 然后发现不是,这样的话,对于每个power,假如我们覆盖到了x,那么我们要找到一个最大的 p <= x 且p 可以放灯,那么转移到的 为止为p + power,这样的话我想复杂度就变成了不是严格的nlogn,但是我写了一发还是过了,我感觉是复杂度接近nlogn,感觉没有 数据能把每个power的check都卡成n. #include<…
G - GCD Counting 思路:我猜测了一下gcd的个数不会很多,然后我就用dfs回溯的时候用map暴力合并就好啦. 终判被卡了MLE..... 需要每次清空一下子树的map... #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define pii pair<int,int> #define piii pair<…
F - Flow Control 给你一个有向图,要求你给每条边设置流量,使得所有点的流量符合题目给出的要求. 思路:只有在所有点的流量和为0时有解,因为增加一条边的值不会改变所有点的总流量和, 所以我们dfs回溯的时候构造就好了, 其他边设为0. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define pii pair<int…
A bracket sequence is a string containing only characters "(" and ")". A regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters "1" and "+"…
A. 一个小模拟 不解释 //By SiriusRen #include <bits/stdc++.h> using namespace std; long long n,m,a,b; int main(){ scanf("%I64d%I64d%I64d%I64d",&n,&m,&a,&b); printf("%I64d\n",min((n%m)*b,(m-(n%m))*a)); } B. 给你一个数列A[i] 把所…
[Educational Codeforces Round 16]E. Generate a String 试题描述 zscoder wants to generate an input file for some programming competition problem. His input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually ge…
[Educational Codeforces Round 16]D. Two Arithmetic Progressions 试题描述 You are given two arithmetic progressions: a1k + b1 and a2l + b2. Find the number of integers x such that L ≤ x ≤ R andx = a1k' + b1 = a2l' + b2, for some integers k', l' ≥ 0. 输入 Th…