码迷,mamicode.com
首页 >  
搜索关键字:poj 2287 贪心    ( 27395个结果
poj 3977 Subset 枚举+二分
首先分成一半2^17和2^18,并且把其中一半变成相反数,然后枚举一半二分查找另一半,在找到的位置前后也找找。 这里用到了二级排序,有很多细节要处理,不多说了。 巨坑的一个地方就是,不能用系统的abs,要自己手写,简直坑死。。 #include #include #include #include using namespace std; typedef long long ...
分类:其他好文   时间:2014-05-22 12:01:31    阅读次数:220
POJ 3070 Fibonacci
Sol:就是求第N项的斐波那契数。矩阵乘法+快速幂 #include #include #include #include using namespace std; #define LL long long struct Mat{ LL f[2][2]; }; LL MOD = 10000; Mat mul(Mat a,Mat b) { LL i,j,k...
分类:其他好文   时间:2014-05-22 10:46:35    阅读次数:191
POJ 3171
题目大意:        给定一个区间范围[M,E],接下来有n行输入,每行输入三个数值:T1,T2,S,表示覆盖区间[T1,T2] 的代价为S,要求你求出覆盖区间[M,E]的最小代价,如果不能覆盖,则输出-1. 解题思路:           先将区间按右端点进行排序,这样我们就能得到dp状态的定义和转移方程:                    dp[i...
分类:其他好文   时间:2014-05-22 10:22:51    阅读次数:309
POJ 3069 Saruman's Army
Saruman's Army Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3519   Accepted: 1787 Description Saruman the White must lead his army along a straight path...
分类:其他好文   时间:2014-05-22 10:09:49    阅读次数:271
poj 2411 Mondriaan's Dream(转态压缩)
题目链接:poj 2411 Mondriaan's Dream 题目大意:用1?2的木块填满n?m的矩阵有多少种方法。 解题思路:插头dp裸题。uva11270 #include #include typedef long long ll; const int N = 13; int n, m; ll set, dp[N+5][(15]; void solve (int d,...
分类:其他好文   时间:2014-05-22 08:06:07    阅读次数:177
POJ 3253 Fence Repair
Fence Repair Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 24153   Accepted: 7703 Description Farmer John wants to repair a small length of the fence aroun...
分类:其他好文   时间:2014-05-22 07:55:44    阅读次数:255
Codeforces 432E Square Tiling(构造+贪心)
题目连接:Codeforces 432E Square Tiling 题目大意:给出一个n?m的矩阵,要求对该矩阵进行上色,用大写字母,但是每次上色的区域必须是正方形,不求相邻的上色区域不能有相同的颜色,求字典序最小的方案(字典序比较,从左至右,从上到下) 解题思路:用贪心的思想去构造矩阵,因为字典序的优先级为左至右,以及上到下,所以我们每次对于一个未上色点x,y,考虑最少要放到的长度...
分类:其他好文   时间:2014-05-22 07:53:17    阅读次数:280
POJ 1979 Red and Black
Red and Black Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 21482   Accepted: 11488 Description There is a rectangular room, covered with square tiles. Eac...
分类:其他好文   时间:2014-05-22 07:09:25    阅读次数:237
codeforces round246 C
像这样的C题对自己来说才是最能提升思维的好题。 首先要知道这些数的组合都是从1-n, 要想对数进行排序,比如pos[i]=4(i位置的数值为4),比较容易能想到i和4直接交换, 题目要求每次交换(i,j)且(j-i+1)为素数,这地方卡住 其实可以利用哥德巴赫猜想(任一大于5的整数都可拆分为三个素数之和,任一大于2的偶数都可拆分为两个素数之和) 然后我们就可以贪心了,先把(j-i+1)拆...
分类:其他好文   时间:2014-05-22 06:36:46    阅读次数:303
POJ 2431 Expedition
ExpeditionTime Limit:  1000MSMemory Limit:  65536KDescriptionA group of cows grabbed a truck and ventured on an expedition deep into the jungle. Being rather poor drivers, the cows unfortunately manag...
分类:其他好文   时间:2014-05-22 06:16:01    阅读次数:423
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!