Digit Holes Time limit: 1000 msMemory limit: 256 MB When writing digits, some of them are considered to have holes: 00, 66 and 99 have one hole, while 88 has two holes. The other digits don't have any holes. Given two integers AA and BB, find a val…
[题解]Comet OJ Round 70 简要题解 A 将放在地上的书按照从小到大排序后,问题的本质就变成了合并两个序列使得字典序最小.可以直接模拟归并排序.直接用循环和std::merge实现这个过程.复杂度\(O(n)\) //@winlere #include<cstdio> #include<algorithm> using namespace std; int data[100003],in[100003],data2[100003],ans[100003],cnt,n…
Problem Description Jam has a math problem. He just learned factorization. He is trying to factorize ax^2+bx+cax2+bx+c into the form of pqx^2+(qk+mp)x+km=(px+k)(qx+m)pqx2+(qk+mp)x+km=(px+k)(qx+m). He could only solve the problem in which p,q,m,…
题目 题目大意 给定平面上的 $n$ 个点和常数 $k$,求 $x$ 轴上的点 $p$ 到 $n$ 个点中距其最近的 $k$ 个点的距离之和的最小值.两点之间的距离定义为曼哈顿距离. 数据范围 $1\le k \le n \le 10^5$ . 点的坐标是 $1$ 到 $10^8$ 之间的整数. 可能有重合的点. 分析 A optimization problem can have many possible solutions. Each solution has a value, and w…
Three Equal Time limit: 1000 msMemory limit: 256 MB You are given an array AA of NN integers between 00 and 22. With cost 11 you can apply the following operation A_i = ((A_i + 1)\ \% \ 3)Ai=((Ai+1) % 3). Find the minimum cost to make all ele…
csa66 Risk Rolls Time limit: 1000 msMemory limit: 256 MB Alena and Boris are playing Risk today. We'll call an outcome the sum of values on the faces of 111 or more rolled dice. Alena has NNN possible outcomes whilst Boris has MMM. In turns, each o…
传送门 题意 给出一个排列,定义\(value为\sum_{i=1}^{n-1}abs(f[i+1]-f[i])\) \(swap(a[i],a[j])(i≠j)为一次交换\),询问最少的交换次数使得value最大 分析 如果f[i+1]>f[i],答案就+f[i+1]-f[i]; 如果f[i+1]<f[i],答案就+f[i]-f[i+1]; 那么我们可以找到一个pretty good solution 定义 L 为 f[i]<=n/2, R 为 f[i]>n/2, 得到L R L…
这次真的好难...... 我这个绿名蒟蒻真的要崩溃了555... 我第二题就不会写...... 暴力搜索MLE得飞起. 好像用到最短路?然而我并没有学过,看来这个知识点又要学. 后面的题目赛中都没看,今天早上看了一下D发现还是能写的. A.You Are Given Two Binary Strings... 简单来说,对f(y)乘以2的k次,实际上就是把这个串左移k位.要使反转的串的字典序最小,就要让f(y)最后的1与f(x)的最后的1的位置对齐. #include<bits/stdc++.h…
噩梦场. 题目出奇的难,好像一群外国老哥看 A 看着看着就哭了-- A 找到 \(b\) 最低的 \(1\),这个 \(1\) 肯定要跟 A 中的一个 \(1\) 搭配,而且是能搭配的 \(1\) 中最低的. #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> PII; const int maxn=100010,mod=998244353; #define…
目录 Contest Info Solutions A. You Are Given Two Binary Strings... B. You Are Given a Decimal String... C. You Are Given a WASD-string... D. Print a 1337-string... E. You Are Given Some Strings... Contest Info Practice Link Solved A B C D E F 5/6 Ø Ø Ø…
比赛链接:https://codeforc.es/contest/1202 A. You Are Given Two Binary Strings... 题意:给出两个二进制数\(f(x)\)和\(f(y)\),定义一个二进制数\(s_k=f(x)+2^k\cdot f(y)\),询问\(k\)取何值时\(s_k\)的反向字符串(将二进制数看作01串)字典序最小. 分析:首先,我们需要知道对于一个二进制数乘2,相当于将该数整体左移一位,因此我们只需要找到\(f(y)\)最右侧的1的位置\(pos…
11.1. Output Formatting 格式化输出 The repr module provides a version of repr() customized for abbreviated displays of large or deeply nested containers: >>> import repr >>> repr.repr(set('supercalifragilisticexpialidocious')) "set(['a',…