灵活题
文章平均质量分 77
ccyy-
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
hznu 1636: 方格取数(dp,灵活题)
设有N*N的方格图(N某人从图的左上角的A 点出发,可以向下行走,也可以向右走,直到到达右下角的B点。在走过的路上,他可以取走方格中的数(取走后的方格中将变为数字0)。此人从A点到B 点共走两次,试找出2条这样的路径,使得取得的数之和为最大。输入 输入的第一行为一个整数N(表示N*N的方格图),接下来的每行有三个整数,前两个表示位置,第三个数为该位置上所放的原创 2015-06-13 22:45:32 · 986 阅读 · 0 评论 -
HDU 5396 Expression(区间DP,排列组合)
http://acm.hdu.edu.cn/showproblem.php?pid=5396思路很特别。大神的详细题解:http://www.cnblogs.com/chenchengxun/p/4741439.html对于加减法,分成左右两块的话,对于左边的某一种运算情况,都要和右边的所有情况匹配,所以【左边】*【右边的全排列】。右边同理。特别拎出来 乘法为什么不用乘上全排列:原创 2015-11-07 12:20:57 · 444 阅读 · 0 评论 -
hdu3687 National Day Parade(排成最后的n*n方阵最少走几步)
There are n×n students preparing for the National Day parade on the playground. The playground can be considered as a n×m grid. The coordinate of the west north corner is (1,1) , and the coordinate of原创 2015-11-07 20:06:38 · 641 阅读 · 0 评论 -
HDU 5353 Average(破解环的做法是枚举起始点の操作,灵活题)
题目链接:点击打开链接(转自:http://www.bubuko.com/infodetail-1024312.html)题目大意:有n个人围城一个环,每一个人手里都有一些糖果,第i个人有ai块。现在有三种操作:第i个人给第i+1个人一块。如果i有第i+1个人给第i个人一块。如果i+1有什么都不做。第i个人和第i+1个人之间,可以选择一种操作并执转载 2015-11-07 19:03:39 · 592 阅读 · 0 评论 -
hdu5402 Travelling Salesman Problem(找规律,构造)
给出一张图,每个点上都有一个非负的数值;要求从左上角走到右下角,走过的点不能再走,得到的最大数值是多少,并输出路线;(转)http://acm.hdu.edu.cn/showproblem.php?pid=5402详细题解:http://www.cnblogs.com/AOQNRMGYXLMV/p/4743293.htmlhttp://blog.youkuaiyun.com/yeyeyeg原创 2015-11-05 19:28:45 · 425 阅读 · 0 评论 -
hdu 2768 二分图匹配(难想到)
题意:有v个观众,每个人投给自己喜欢的猫(或者狗)和讨厌的狗(或者猫),如果出现喜欢的和别人讨厌的相同,则其中一人会不满意。 现要求得是最大满意的观众是多少。 方法:根据出现矛盾的两个观众序号建边。现在选择最多的顶点,要求各个顶点之间没有线相连,即不出现矛盾。就是求最大独立集。 最大匹配:二分图G中,找出边数最大的子图M,使得M中各条边均无公共顶点,则M为最大匹配。可用匈牙利算法求得。转载 2015-10-02 23:58:09 · 506 阅读 · 0 评论 -
【codechef】Devu and his Class(巧妙的 模拟,分类讨论)
Devu is a class teacher of a class of n students. One day, in the morning prayer of the school, all the students of his class were standing in a line. You are given information of their arrangement by原创 2015-04-11 17:42:48 · 801 阅读 · 0 评论 -
hihocoder 1166 交换代数|HDU 4870 Rating 等(区间翻转,高斯消元求期望)
少女幽香这几天正在学习交换代数,然而她什么也没有学会,非常痛苦。于是她开始玩起了一个简单的小游戏,来放松一下。地面上一共有n个球,一开始有一些是黑色的,有一些是白色的。每次她随机选择一个区间(一共有n(n+1)/2个区间,每个区间有相等的概率被选择),把这个区间的颜色反转,即将该区间中白球变黑球,黑球变白球。现在她想要知道期望情况下,多少次反转能够使得整个区间都是白色的。输入第原创 2015-05-12 11:26:35 · 977 阅读 · 0 评论 -
Tokyo2014 There is No Alternative (最小生成树,灵活题)
Input Output Sample Input4 41 2 31 3 2 3 32 4 3Sample Output1 3给出一个图,求所有最小生成树的可能情况都会加进去的边的个数和总和。逆向思维。由于这条边在所有最小生成树中必会出现,所以,如果删除这条边,那么最小生成树的值就肯定会发生变化。原创 2015-08-30 21:37:26 · 531 阅读 · 0 评论 -
poj1426 Find The Multiple(哈夫曼思想)
Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains only the digits 0 and 1. You may assume that n is not greater than 200 and there原创 2015-08-30 23:07:31 · 2083 阅读 · 1 评论 -
【codechef】Chef and the Number Sequence(构成最长公共子序列为L的可能性)
大厨拥有一个长度为 N 的序列 A,其中的每个元素都是 1 到 K 之间的整数(包括 1 和 K)。现在大厨想要得到到另一个序列 B,它的长度与 A 同为 N,而且每个元素也都是 1 到 K 之间的整数(同样包括 1 和 K)。大厨要求序列 A 和序列 B 的最长公共子序列的长度恰好为 L。请你求出有多少个序列 B 可以满足大厨的要求。由于答案可能非常大,请输出答案对 109 + 7 取模之后的结原创 2015-08-28 19:53:41 · 780 阅读 · 2 评论 -
CERC2014 Outer spaceinvaders(区间DP,推理)
有N个外星人,第i个外星人会在ai时间出现,离你距离di,并且必须在bi时间之前被消灭。你有一把很NB的武器,攻击范围是个半径为R的圆,R可以任意调整,不过你以R的范围每攻击一次就要消耗R单位能量。外星人被攻击一次就会死掉。求需要消灭所有外星人的最小消耗能量。 dp[i][j] = min(dp[i][j], c[h]+ f[i][k] + f[k][j])(a[h]是i秒到j秒里出现的d原创 2015-08-26 14:14:55 · 1060 阅读 · 0 评论 -
【codechef】 Special Economic Zone(二分图匹配,难想到)
Input:6 51 22 34 55 66 4Output:1ExplanationCiel will select city 1 and 3 as SEZ. So x = 2 (city 1 and 3), y = 1 (city 2), x - y = 1.http://www.codechef.com/MAY15/problems/SEZ/原创 2015-05-22 14:46:41 · 620 阅读 · 0 评论 -
hznu 1628: 旅行家的预算(贪心,分类)
一个旅行家想驾驶汽车以最少的费用从一个城市到另一个城市(假设出发时油箱是空的)。给定两个城市之间的距离D1、汽车油箱的容量C(以升为单位)、每升汽油能行驶的距离D2、出发点每升汽油价格P和沿途油站数N(N可以为零),油站i离出发点的距离Di、每升汽油价格Pi(i=1,2,……,N)。计算结果四舍五入至小数点后两位。如果无法到达目的地,则输出“No Solution”。输入原创 2015-06-11 23:36:16 · 862 阅读 · 0 评论 -
hznu 1164 Unidirectional TSP(记录状态的DP)
Problems that require minimum paths through some domain appear in many different areas of computer science. For example, one of the constraints in VLSI routing problems is minimizing wire length. Th原创 2015-06-11 20:43:39 · 558 阅读 · 0 评论 -
CF 549D. Haar Features(神奇,不知道怎么推出来的)
The first algorithm for detecting a face on the image working in realtime was developed by Paul Viola and Michael Jones in 2001. A part of the algorithm is a procedure that computes Haar features. A原创 2015-06-09 18:55:25 · 985 阅读 · 0 评论 -
CF 549H. Degenerate Matrix(二分,退化矩阵灵活题)
The determinant of a matrix 2 × 2 is defined as follows:A matrix is called degenerate if its determinant is equal to zero.The norm ||A|| of a matrix A is defined as a maximum of absolute v原创 2015-06-09 13:16:55 · 1711 阅读 · 0 评论 -
【百度之星初赛2】魔法因子|乘某个数首末位互换(数学,灵活题)
有人说:人类是自己一步步进化的,而数学是上帝亲手创造的。度度熊最近也正沉醉于数学之美中,它发现了一种神奇的数字,取名曰:魔法因子。将因子记为X,如果有一些整数与这些因子做乘法后,结果仍然是整数,同时,结果数字的首位和末位会换交换位置,而其他位置上的数字恰好不变!这时X被认为是一个魔法因子。需要注意的是,用来相乘的这些整数不会含有前导0,但是如果交换的结果有前导0,又恰好是乘法的结果,这时仍原创 2015-05-31 23:04:46 · 1030 阅读 · 0 评论 -
poj 2786 Keep the Customer Satisfied(贪心+优先队列)
InputThe first line contains the number n of orders (n can be as large as 800000 for some test cases). It is followed by n lines. Each of which describes an order made of two integer values: the a原创 2015-06-07 18:27:32 · 615 阅读 · 0 评论 -
poj 3045 Cow Acrobats(灵活题,推论)
Farmer John's N (1 <= N <= 50,000) cows (numbered 1..N) are planning to run away and join the circus. Their hoofed feet prevent them from tightrope walking and swinging from the trapeze (and their las原创 2015-06-07 19:27:56 · 469 阅读 · 0 评论 -
【codechef】Lazy Players
Concerned with the fitness levels of the players in the National Team, the coach decides to carry out a running drill in the next training session. So, he sets up checkpoints in the training ground at原创 2015-04-30 22:03:59 · 520 阅读 · 0 评论 -
HDU 4445 Crazy Tank (物理题,枚举角度)
Crazy Tank was a famous game about ten years ago. Every child liked it. Time flies, children grow up, but the memory of happy childhood will never go.Now you’re controlling the tank Laotu on a原创 2015-05-19 23:21:31 · 548 阅读 · 0 评论 -
【百度之星初赛2】序列变换(最长上升子序列)
我们有一个数列A1,A2...An,你现在要求修改数量最少的元素,使得这个数列严格递增。其中无论是修改前还是修改后,每个元素都必须是整数。请输出最少需要修改多少个元素。 Input第一行输入一个T(1≤T≤10),表示有多少组数据每一组数据:第一行输入一个N(1≤N≤105),表示数列的长度第二行输入N个数A1,A2,...,An。每原创 2015-05-31 22:45:24 · 1238 阅读 · 0 评论 -
求能覆盖到所有点的最少集合情况(超时题,须优化)
4 //t组样例3 5 //3个集合,5个点2 2 1 //2大小,覆盖点2和点11 4 //1大小,覆盖点42 3 5 //2大小,覆盖点3和点53 3 //3个集合,3个点3 1 2 3 //3大小,覆盖点1和点2和点33 2 3 1 //3大小,覆盖点2和点3和点13 3 1 2 //3大小,覆盖点3和点1和点23 3原创 2016-02-02 22:02:22 · 709 阅读 · 0 评论 -
hznu 1524 排队买票(dp)【类卡特兰构造】
有M个小孩到公园玩,门票是1元。其中N个小孩带的钱为1元,K个小孩带的钱为2元。售票员没有零钱,问这些小孩共有多少种排队方法,使得售票员总能找得开零钱。注意:两个拿一元零钱的小孩,他们的位置互换,也算是一种新的排法。(M<=10)输入输入一行,M,N,K(其中M=N+K,M<=10)。输出输出一行,总的排队方案。样例输入4 2 2样例输出8http://hsacm.cn/JudgeOn...原创 2015-05-03 20:07:32 · 2944 阅读 · 1 评论 -
给出一个数字m,求满足m = a^3 + b^3(a,b为正整数)的所有整数对(分解素因子防超时)
题目连接:ZOJ-3673题目大意:给出一个数字m,求满足m = a^3 + b^3(a,b为正整数)的所有整数对。题目思路:已知 m =a3+b3=(a+b)(a2−a∗b+b2) ①设 t = a + b; ②②代入①,因为 m = (a+b)((a+b)2−3∗a∗b)可得,n = a∗b=(t2−m/t)/3–>a2+a∗t+n=0;原创 2016-03-28 12:41:49 · 1319 阅读 · 0 评论 -
hdu4190 n个城市,m个投票箱。求票数最大的投票箱内票数最少时的数目
样例输入:2 72000005000004 612026803400200-1 -1样例输出:1000001700有n个城市,m个投票箱。每个城市的人口分别是xi。求票数最大的投票箱内票数最少时的数目。思路:尽量均分。【二分版】#include #include #include #include #include #原创 2016-04-17 16:08:38 · 820 阅读 · 0 评论 -
ZOJ 3790 Consecutive Blocks 最多删k个数求最长连续相同序列长度
题解:http://blog.youkuaiyun.com/csuhoward/article/details/38366737#include using namespace std; struct node{ int a,b,c,e; node(int aa=0,int bb=0,int cc=0,int ee=0){ a=aa;b=bb;c原创 2016-03-23 19:18:11 · 795 阅读 · 0 评论 -
田忌赛马,求赢得的最大分数(分类,脑洞题)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1052题解:http://blog.youkuaiyun.com/dgq8211/article/details/7370765关键的话是要想到从田最慢和齐最慢的比较寻找方案。。。#includeusing namespace std;int tian[1005],qi[1005];int n;in原创 2016-03-28 15:40:58 · 843 阅读 · 0 评论 -
ZOJ3805 Machine I型和L型的管道最少多宽?(贪心)
输入的x[i]代表有管道从i点接到x[i]点。注意整个图其实是个变相的倒树,并且需要灵活运用【The same code will be appeared at most twice】这句话联想到其实还是棵二叉树。由于管道可以无限长,所以某个节点向上延伸的左右子节点可以错开不在同一行,但是别忘了管道本身也占了一单位宽。#include #define ll long longusin原创 2016-03-23 23:28:17 · 492 阅读 · 0 评论 -
每次可以从里面拿出一个放在最前(或最后),求最小的次数把数列排好序
每次可以从里面拿出一个放在最前或最后,求最小的次数把数列排好序 http://codeforces.com/problemset/problem/606/C#include #define ll long longusing namespace std; int x[100005];int main(){ int n,a,maxx=0; cin>>n; for(int i=原创 2016-03-23 21:45:56 · 2724 阅读 · 1 评论 -
CF629C 在s两端在加两个串p和q 使得总长度为n,并且最后的s'符合规范的方法
给你一个长度为m的只含()的括号串s, 要求在s两端在加两个串p和q, 使得总长度为n,并且最后的s'(即p+s+q)是符合规范的。求添加p、q的方法数可以在现有思路上+点击打开链接这题二维代码的理解。还有一种做法:点击打开链接原创 2016-02-23 22:37:52 · 1544 阅读 · 0 评论 -
【经典】有K张折扣券和m元最多能买多少物品(折前价ai,折后价bi)
这真是很玄学的一道题,贪心也要贪好几次。。。题解:http://blog.youkuaiyun.com/snowy_smile/article/details/50774455题解:http://blog.youkuaiyun.com/imwutianqi/article/details/50895167#include#define ll long longusing namespace std;st原创 2016-03-31 17:34:10 · 1597 阅读 · 0 评论 -
从n到m,有-1和*2两种操作。问最少走几步
从n到m,有-1和*2两种操作。问最少走几步。这题必须从m来逆向考虑。#include using namespace std;int main(){ int count =0; int m,n; cin>>n>>m; while(n < m){ if(m%2) m++; else m/=2; count++; } cout<<count+n-m<原创 2016-03-18 23:20:02 · 1735 阅读 · 0 评论 -
CF507C 给定一种二叉树的走法,问到第n个叶子结点之前,有多少个结点被走过
#include #define ll long longusing namespace std;int main(){ ll h,n; cin>>h>>n; ll l=0,r=pow(2,h); //或者写成(1ll<<h),ll一定要加!! int p=0; //表示初始往左走,1表示往右走 ll s=0; while(h){原创 2016-02-21 22:11:18 · 979 阅读 · 0 评论 -
CF 549G swap(前-1,后+1),问是否能变成递增序列(灵活题)
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原创 2015-06-21 22:57:39 · 626 阅读 · 0 评论 -
是否可以删除一个字母之后变成回文串
题目描述给出一个字符串,仅由小写字母组成。请找出是否仅删除其中的一个字母之后, 字符串变成回文串。输入输入第一行是一个整数 T,表示有 T 组数据。 每组数据占一行,每行包含一个非空字符串,字符串长度不超过 105 。 输出对于每组测试数据,输出一行包含一个整数 K ,表示删除字符串中第 K 个字原创 2016-02-02 16:27:15 · 1786 阅读 · 0 评论 -
SDUT3173 有多少个连续子序列的和能被k整除
题目描述Edward 得到了一个长度为 N 的整数序列,他想找出这里面有多少个“幸运的”连续子序列。一个连续子序列被称为“幸运的”,当且仅当该子序列内的整数之和恰好是 K 的整数倍数。他请求你写一个程序来计算他喜欢的连续子序列个数。输入 输入第一行是一个整数 T,表示有 T 组数据。每组数据第一行是两个整数 N (1 接下来的一行包含 N 个整数 A i (|A原创 2016-02-02 14:25:56 · 4899 阅读 · 0 评论 -
hdu4982 是否存在k个数和为n并且存在其中k-1个数和为完全平方数的情况
k个数必须是各不相同的。这题属于思维错误题。http://acm.hdu.edu.cn/showproblem.php?pid=4982#include #include #include #include #include #include #include #include #include #define ll long long usin原创 2016-02-01 22:04:28 · 701 阅读 · 0 评论 -
在O(logn)时间内找到数组中离每个数最近而又比它大的数的下标
题目描述 Farmer Zhao's N cows (1 ≤ N ≤ 1,000,000) are lined up in a row. So each cow can see the nearest cow which is taller than it. You task is simple, given the height (0 9) of each cow lined up i原创 2016-02-06 22:33:06 · 1880 阅读 · 0 评论
分享