题目链接:https://cn.vjudge.net/contest/285962#problem/G 题目大意:给你n和m,n代表有n个数,然后让你找出一个最长的区间,使得这个区间内的所有的数的‘’或‘’都小于等于m. 具体思路:曲尺,两个指针来回弄就行,具体的细节在代码里面,(以前做过的题现在竟然做不出来了,,我) AC代码: #include<iostream> #include<stack> #include<stdio.h> #include<cmath…
题目链接:https://codeforces.com/gym/102028/problem/C Lewis likes playing chess. Now he has n rooks on the chessboard with $n$ rows and $n$ columns. All rows of the chessboard are labelled with $1$ through $n$ from top to bottom. All columns of the chessb…
题目链接:http://codeforces.com/gym/101775/problem/C 题意: 给出 $N$ 个红绿灯,又给出 $N+1$ 个距离 $S_i = S_0,S_1, \cdots, S_N$,代表从第 $i$ 个路灯到第 $i+1$ 个路灯的距离(第 $0$ 个距离代表从家到第一个红绿灯的距离,第 $N$ 个距离代表从最后一个红绿灯到公司的距离). 现在每个红绿灯有 $A_i$ 秒的绿灯时长,$B_i$ 秒的红灯时长,所有的红绿灯的 $A_i + B_i$ 都相等,你可以通…
题目:传送门.(需要下载PDF) 题意:给定一个长度不超过1000的字符串表达式,向该表达式中加入'+'或'-',使得表达式的值最大,输出该表达式. 题解:比如300-456就改成300-4+56,遇到二位数以上的减数的情况就变成-首位+剩下的,这样会使得表达式值最大. #include <iostream> #include <cstdio> #include <cmath> #include <cstring> using namespace std;…
题目链接:https://cn.vjudge.net/contest/285964#problem/A 题目大意:每一次给你你一个数,然后对于每一次操作,可以将当前的数的每一位互换,如果互换后的数小于等于原来的数,那么停止操作,如果大于原来的数,则继续操作,到达当前这些数字能租成的最大的数的时候停止,然后问你能组成最大的数概率是多少? 具体思路:对于当前的数,我们先计算出这个比这个数大的有多少个,这个过程可以通过全排列的函数来进行计算.然后再计算一下当前的位数能构成的数的个数是多少,然后就开始求…
UVA 1394 And Then There Was One / Gym 101415A And Then There Was One / UVAlive 3882 And Then There Was One / POJ 3517 And Then There Was One / Aizu 1275 And Then There Was One (动态规划,思维题) Description Let's play a stone removing game. Initially, n ston…
题目传送门 /* 题意:一个n×m的矩形,相邻的颜色不同,黑或白.问最少的翻转次数,每次翻转可指定任意一个子矩形 思维题:最少要把偶数行和列翻转,也就是n/2+m/2次 */ #include <cstdio> using namespace std; int main(void) //Gym 100553A Alter Board { // freopen ("A.in", "r", stdin); freopen ("alter.in&qu…
C. Nice Garland time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have a garland consisting of nn lamps. Each lamp is colored red, green or blue. The color of the ii-th lamp is sisi ('R',…
Online Judge:UVA12235 Label:思维题,状态定义,状压Dp 题面: 题目描述 有一个书架,上面放了n本书,从左往右的第i本书的高度为h[i].定义书架的混乱度为连续等高段的个数. 例如:{30,30,31,31,32}的混乱度为3:{30,32,32,31}的混乱度为3:{31,32,31,32,31}的混乱度为5. 现在你可以从中抽出至多k本书,然后将他们随意放回书架任意位置,求最终最小的混乱度. 对于100%的数据,N的范围[1,500],K的范围[1,100],书的…
题目地址: 选题为入门的Codeforce div2/div1的C题和D题. 题解: A:CF思维联系–CodeForces -214C (拓扑排序+思维+贪心) B:CF–思维练习-- CodeForces - 215C - Crosses(思维题) C:CF–思维练习–CodeForces - 216C - Hiring Staff (思维+模拟) D:CF思维联系–CodeForces-217C C. Formurosa(这题鸽了) E:CF思维联系–CodeForces - 218C E…