题目链接:https://www.nowcoder.com/acm/contest/146/G G.Counting regions | 时间限制:1 秒 | 内存限制:128M Niuniu likes mathematics. He also likes drawing pictures. One day, he was trying to draw a regular polygon with n vertices. He connected every pair of the verti…
题目传送门 题意: 输入一段字符串,字符串中连续的三个相同的字符可以消去,消去后剩下的左右两段字符串拼接,求最多可消去次数. 输入:ATCCCTTG   输出:2 ATCCCTTG(消去CCC)——>ATTTG(消去TTT)——>AG 题解: 签到题,用栈模拟即可. Code: 用栈模拟: /*7ms*/ 1 #include<bits/stdc++.h> using namespace std; ; int main() { string str; while(!(cin>…
题意: 对于一个序列,把可以把连着三个相同的字母拿走,问最多拿走多少组. 题解: 直接模拟栈,三个栈顶元素相同则答案+1,并弹出栈 #include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int, LL>P; ; ; const LL lINF = 0x3f3f3f3f3f3f3f3f; #define ls (rt<<1) #define rs (rt<<…
[HDU6304][数学] Chiaki Sequence Revisited -杭电多校2018第一场G 题目描述 现在抛给你一个数列\(A\) \[ a_n=\begin{cases}1 & n = 1,2 \\ a_{n - a_{n-1}} + a_{n-1 - a_{n-2}} & n \ge 3\end{cases} \] 现在需要你计算它的前缀和 \(\sum\limits_{i=1}^{n}a_i \ mod \ (10^9+7)\) 数据范围 \(n(1\le n\le…
牛客多校第三场 G Removing Stones(分治+线段树) 题意: 给你n个数,问你有多少个长度不小于2的连续子序列,使得其中最大元素不大于所有元素和的一半 题解: 分治+线段树 线段树维护最大值的位置,每次分治找就找这个最大值,然后看最大值在哪个序列是可行的 怎么看最大值所在的序列是否可行呢? 我们用一个前缀和维护区间和 \[ max<=\frac{1}{2}(sum[r]-sum[l])\\ 2*max-(sum[r]-sum[l])<=0\\ \] 这个最大值在这一段区间内都有可…
2019牛客多校第八场 F题 Flowers 先枚举出三角形内部的点D. 下面所说的旋转没有指明逆时针还是顺时针则是指逆时针旋转. 固定内部点的答案的获取 anti(A)anti(A)anti(A)或者说A‾\overline{A}A表示DA→\overrightarrow{DA}DA旋转180°之后的方向. block(A,B)block(A,B)block(A,B)表示的是DA→\overrightarrow{DA}DA旋转到DB→\overrightarrow{DB}DB的扫过的几何区间.…
__int128(例题:2020牛客多校第八场K题) 题意: 有n道菜,第i道菜的利润为\(a_i\),且有\(b_i\)盘.你要按照下列要求给顾客上菜. 1.每位顾客至少有一道菜 2.给顾客上菜时,都必须从第一道菜开始,上连续的编号的菜,例如,你可能给一位顾客 上的菜为第一道,第二道,第三道,但是不能为只上第二道而不上第一道,或者第一道,第三道中间缺少第二道. 求这些菜能够容纳的最大顾客数,并且求出在容纳最多顾客时的利润最大为多少. 数据范围 \(1\le n\le 10^{5}\),\(-1…
A. Coins Alice and Bob are playing a simple game. They line up a row of nnn identical coins, all with the heads facing down onto the table and the tails upward. For exactly mmm times they select any kkk of the coins and toss them into the air, replac…
链接:https://www.nowcoder.com/acm/contest/142/G来源:牛客网 The mode of an integer sequence is the value that appears most often. Chiaki has n integers a1,a2,...,an. She woud like to delete exactly m of them such that: the rest integers have only one mode an…
链接:https://www.nowcoder.com/acm/contest/140/G White Cloud placed n containers in sequence on a axes. The i-th container is located at x[i] and there are a[i] number of products in it. White Rabbit wants to buy some products. The products which are re…