这个题就是一块大板子,问你能不能切成两块要求的长宽的两块板子,一开始是按切板子想的,感觉有点麻烦. 直接反过来想,把两块要求的板子拼起来,填成一个大板子,看填出来的这个板子和题目给的板子比较,小于等于就满足. 想了一下是四种情况,直接贴一下草稿纸上画的,丑乎乎的( ̄▽ ̄)/ 代码虽然长,但是直接复制粘贴条件改一下就可以. 代码: 1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 #include&…
这个题就是两个队,看最多能赢的个数,然后比较一下,看两个队是都能赢彼此,还是只有一个队赢的可能性最大.表达能力不好,意思差不多... 和田忌赛马有点像,emnnn,嗯. 代码: 1 #include<cstring> 2 #include<cstdio> 3 #include<cstdlib> 4 #include<cmath> 5 #include<iostream> 6 #include<algorithm> 7 using na…
这个题就是从字符串中删除一个字符,然后剩下的是回文串. 我写的代码虽然长得好看,但是循环里面的比较条件容易想错,太智障了... 一开始写的是计数比较,但是有的时候下标相同的也比较了,为了简单一些,直接看有没有条件不成立的,这样就少想好多东西(偷懒为主,嘻嘻嘻). 代码: #include<cstdio> #include<cstring> #include<iostream> #include<cmath> #include<algorithm>…
这个题直接推公式就可以. 就是解一元二次方程,用高中学的公式,函数开口向上,求最大值为(4ac-b*b)/4a. 这个题推出来一元二次方程,然后将最大值的公式化简一下.公式很好推. 这个题有疑问,int vx=v11-v1,vy=v22-v2;这样写是对的,反过来写成v1-v11,v2-v22就不对,WA1,但是样例什么的是对的,搞不懂为什么. 代码: 1 #include<cstdio> 2 #include<cstring> 3 #include<iostream>…
这个题就是组三角形,从给出的数组里任选两个和未知的边组三角形. 任意两边之和大于第三边,记住这个就可以了. 代码: 1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 #include<cmath> 5 #include<algorithm> 6 using namespace std; 7 const int N=1e6+10; 8 int a[N]; 9 int main…
昨天训练打的Gym,今天写题解. 这个题就是输出的时候有点小问题,其他的都很简单. 代码: #include<iostream> #include<cstring> #include<cstdio> using namespace std; ; int a[N]; int main(){ int n; while(~scanf("%d",&n)){ ; ;i<=n;i++){ scanf("%d",&a[i]…
昨天训练打的Gym,今天写题解. Gym100971B 这个题就是输出的时候有点小问题,其他的都很简单. 总之,emnnn,简单题. 代码: #include<iostream> #include<cstring> #include<cstdio> using namespace std; ; int a[N]; int main(){ int n; while(~scanf("%d",&n)){ ; ;i<=n;i++){ scanf…
题意:在\(x\)轴上有很多传送点和钻石,当位于传送点上时,可以传送到其他任意传送点(不记操作数),位于钻石上时可以吃掉它,每次可以移动一个单位,问最少多少次可以吃掉所有的钻石. 题解:对于某个位置上的钻石,我们可以从它左边的传送点走过来,或者从它右边的传送点走过来,又或者从上一个钻石的位置直接走过来,我们每次在这三个距离中取最小即可.具体怎么实现呢?我们首先考虑左右传送点的情况,遍历每个钻石的位置,然后记录当前这个钻石到左传送点或右传送点的最小距离,之后再次遍历钻石位置,比较\(上个钻石走回传…
ACM思维题训练集合 There is a board with a grid consisting of n rows and m columns, the rows are numbered from 1 from top to bottom and the columns are numbered from 1 from left to right. In this grid we will denote the cell that lies on row number i and col…
原题:http://codeforces.com/contest/675/problem/C 让我们用数组a保存每个银行的余额,因为所有余额的和加起来一定为0,所以我们能把整个数组a划分为几个区间,每个区间的和都为0.对于每个区间来说,设该区间长度为l,则让该区间都为0的操作数为l-1,例如:1 .1 .-3 .1的操作数为3,也就是说,若把a分成k个区间,则a所需要的总的操作数为n-k. 所以现在我们的目标就是把数组a划分为尽可能多的部分,这个时候我们可以用一个map,统计前缀和的个数,因为对…
题目链接:https://codeforces.com/contest/1090/problem/D Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these…
D. Minimum Triangulation time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given a regular polygon with nn vertices labeled from 11 to nn in counter-clockwise order. The triangulatio…
A #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) #define TS printf("!!!\n") #define pb push_back #define inf 1e9 //std::ios::sync_with_stdio(false); using namespace std; //priority_queue<int,vect…
题目地址: 选题为入门的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…
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',…
http://codeforces.com/problemset/problem/1009/B B. Minimum Ternary String time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given a ternary string (it is a string which consists only…
题目传送门 /* 题意:套娃娃,可以套一个单独的娃娃,或者把最后面的娃娃取出,最后使得0-1-2-...-(n-1),问最少要几步 贪心/思维题:娃娃的状态:取出+套上(2),套上(1), 已套上(0),先从1开始找到已经套好的娃娃层数, 其他是2次操作,还要减去k-1个娃娃是只要套上就可以 详细解释:http://blog.csdn.net/firstlucker/article/details/46671251 */ #include <cstdio> #include <algor…
Each month Blake gets the report containing main economic indicators of the company "Blake Technologies". There are n commodities produced by the company. For each of them there is exactly one integer in the final report, that denotes correspond…
https://vjudge.net/problem/2135388/origin Describe You are given an integer sequence 1,2,-,n. You have to divide it into two sets A and B in such a way that each element belongs to exactly one set and |sum(A)−sum(B)| is minimum possible. The value |x…
题面传送门 很容易发现一件事情,那就是数组的每一位都是独立的,但由于这题数组长度 \(n\) 很大,我们不能每次修改都枚举每一位更新其对答案的贡献,这样复杂度必炸无疑.但是这题有个显然的突破口,那就是 \(k\) 的取值范围很小,最高只有 \(12\),也就是说每一位的取值最多只有 \(12\) 种可能,我们考虑以此为突破口,设计一个与这 \(k\) 个数的具体取值无关的状态. 首先我们知道每一位是独立的,故我们可以把每一位拆开来考虑,于是问题由二维变成一维:给定 \(k\) 个数 \(a_1,…
ACM-ICPC 2018 徐州赛区网络预赛 G. Trace (思维,贪心) Trace 问答问题反馈 只看题面 35.78% 1000ms 262144K There's a beach in the first quadrant. And from time to time, there are sea waves. A wave ( xx , yy ) means the wave is a rectangle whose vertexes are ( 00 , 00 ), ( xx ,…
题目:http://codeforces.com/contest/374/problem/A 题意:求到达边界的最小步数.. 刚开始以为是 bfs,不过数据10^6太大了,肯定不是... 一个思维题,要注意超边界... #include <iostream> #include <cstring> #include <algorithm> using namespace std; <<); int n,m,x,y,a,b; int ok(int x1,int…
题目传送门 /* 题意:一个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…
Codeforces 1207 G. Indie Album 解题思路 离线下来用SAM或者AC自动机就是一个单点加子树求和,套个树状数组就好了,因为这个题广义SAM不能存在 \(len[u] = len[fa]\) 的节点,需要特殊处理,所以写一个博客来贴板子,之前用Awd博客上的那个好像不太能处理干净. code /*program by mangoyang*/ #include <bits/stdc++.h> #define inf ((ll) 1e18) #define Max(a,…
Online Judge:Luogu,Codeforces Round #592 (Div. 2) C Label:数学,思维题, 枚举 题目描述 某球队一共打了\(n\)场比赛,总得分为\(p\),已知赢一场得\(w\)分,平局一场得\(d\)分,输一场不加分也不减分,问一共赢了几场(x),平局了几场(y),输了几场(z)?如果不存在合法方案输出"-1",如果存在多组可能的方案,任意输出一组(Special Judge). 也就是任求一组符合条件的非负整数三元组\((x,y,z)\)…
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],书的…
[codeforces 549]G. Happy Line 试题描述 Do you like summer? Residents of Berland do. They especially love eating ice cream in the hot summer. So this summer day a large queue of n Berland residents lined up in front of the ice cream stall. We know that ea…
题目 题意:一个人可以在一分钟同时进行m道菜的一个步骤,共有n道菜,每道菜各有xi个步骤,求做完的最短时间. 思路:一道很水的思维题, 根本不需要去 考虑模拟过程 以及先做那道菜(比赛的时候就是这么考虑的). 只是需要判断总数的平均值 和 耗时最大的一道菜 哪个最大.. #include <iostream> #include <cstdio> #include <cstring> #include <cstring> #include <cmath&…
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3829 现场做这道题的时候,感觉是思维题.自己智商不够.不敢搞,想着队友智商好,他们搞吧.可是没出来这题...... 以后不论什么时候,都自信点....该想的还是好好自己想,这类题感觉就是先去找性质,然后一点点找规律,假设必要的话.自己提出一点猜想.然后假设自己举不出来反例,就临时觉得是正确的 下午搞了一下午.发现还是悲剧,晚上參考了两个题解 http://blog.csd…
思维题,好题 把每条边的边权平分到这条边的两个顶点上,之后就是个sb贪心了 正确性证明: 如果一条边的两个顶点被一个人选了,一整条边的贡献就凑齐了 如果分别被两个人选了,一作差就抵消了,相当于谁都没有 代码 #include <bits/stdc++.h> #define rep(i,x,y) for(i=(x);i<=(y);++i) using namespace std; double a[10010]; int main(){ int n,m,i,x,y,z; double an…