Codeforces Round #493 (Div. 1)】的更多相关文章

目录 Codeforces 998 A.Balloons B.Cutting C.Convert to Ones D.Roman Digits E.Sky Full of Stars(容斥 计数) Codeforces 998 比赛链接 A.Balloons 输出啥看错WA\(*2\)+第一次写sort写了cmp()但是没加cmpWA\(*2\)(结构体重载运算符后遗症).. 没谁了. #include <cstdio> #include <cctype> #include <…
Cutting There are a lot of things which could be cut — trees, paper, “the rope”. In this problem you are going to cut a sequence of integers. There is a sequence of integers, which contains the equal number of even and odd numbers. Given a limited bu…
C - Convert to Ones 给你一个01串 x是反转任意子串的代价 y是将子串全部取相反的代价 问全部变成1的最小代价 两种可能 一种把1全部放到一边 然后把剩下的0变成1  要么把所有的 0 直接变成1 #include<bits/stdc++.h> using namespace std; #define LL long long int main(){ LL n,x,y; string a; cin>>n>>x>>y>>a; ;…
A. /* 发现每次反转或者消除都会减少一段0 当0只有一段时只能消除 这样判断一下就行 */ #include<cstdio> #include<algorithm> #include<cstring> #include<iostream> #include<set> #include<map> #define M 300010 #define ll long long using namespace std; int read()…
D. Roman Digits time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 显然只有在前i个位置奇数偶数出现次数都相同的地方才能切. (且不管前面怎么切,这里都能切的. 那么就相当于有n个物品,每个物品的代价是|a[i]-a[i-1]|,然后价值是1. 因为价值是一样的..所以肯定优先选价值最小的几个... 直接sort就可以了.. [代码] #include <bits/stdc++.h> using namespace std; const int N = 100; const int INF =…
由于是输出任意一组解,可以将价值从小到大进行排序,第一个人只选第一个,第二个人选其余的.再比较一下第一个人选的元素和第二个人所选元素和是否相等即可.由于已将所有元素价值从小到大排过序,这样可以保证在有解的情况下一定可以构造出可行解. Code: #include<iostream> #include<algorithm> using namespace std; const int maxn = 100000 + 3; int a[maxn], A[maxn]; bool cmp(…
题意: 我们在研究罗马数字.罗马数字只有4个字符,I,V,X,L分别代表1,5,10,100.一个罗马数字的值为该数字包含的字符代表数字的和,而与字符的顺序无关.例如XXXV=35,IXI=12. 现在求问一个长度为 nnn 的罗马数字可以有多少种不同的值. n<=109n<=10^9n<=109. 题解: 我们可以用暴力的方法求出前20项的值,其中前111111 项采用打表的方式,而从第12项开始答案始终 = 前一项的答案 + 49,即 292+(n−11)∗49292+(n-11)*…
题意: 给你一个长度为 nnn 的 010101串 ,你有两种操作: 1.将一个子串翻转,花费 XXX 2.将一个子串中的0变成1,1变成0,花费 YYY 求你将这个01串变成全是1的串的最少花费. 首先,我们可以将串按照0,10,10,1这划分,例如: «00011001110»−>«000»+«11»+«00»+«111»+«0»«00011001110» -> «000» + «11» + «00» + «111» + «0»«00011001110»−>«000»+«11»+«0…
不解释,题目过水 Code: #include<cstdio> #include<cmath> #include<algorithm> using namespace std; const int maxn = 1000 + 3; int A[maxn], n, odds[maxn], f[200][200],b; int main() { scanf("%d%d",&n,&b); for(int i = 1;i <= n; +…