码迷,mamicode.com
首页 >  
搜索关键字:using    ( 53562个结果
13 URAL1303 Minimal Coverage
给cnt条线段,要求覆盖[0,m],问能否覆盖,至少需要多少条线段。 用贪心的想法,假设当前位置在now,那么此时添加一条线段使得左端点 下次继续添加这样一条线段,使得右端点最远,左端点 扫完所有线段,now的位置可以到达m,则有解,否则无解。 #include #include using namespace std; struct node { int l,r;...
分类:其他好文   时间:2015-05-02 22:07:26    阅读次数:197
第k短路
poj 2449 模板题 A*+spfa 1 #include 2 #include 3 #include 4 #include 5 #define mt(a,b) memset(a,b,sizeof(a)) 6 using namespace std; 7 const int inf...
分类:其他好文   时间:2015-05-02 21:56:33    阅读次数:145
线段树水题 #1077 : RMQ问题再临-线段树
#include #include #include #include #include using namespace std; #define maxn 1000000 + 10 #define Lson L, mid, root<<1 #define Rson mid+1, R, root<<1|1 #define INF 0x7ffffff int Min[maxn<<2],...
分类:其他好文   时间:2015-05-02 20:47:23    阅读次数:125
杭电ACM1194——Beat the Spread!
简单的数学题目,就是解方程。 不过需要注意的是,解出来的两个解没有负数。 输入m和n,方程1:x + y = m;方程2:| x - y | = n; x = (n + m)/ 2; y = (-n + m)/ 2; 注意:n + m和m - n 必须是偶数!~~做个判断就OK了。 AC的代码: #include using namespace std; int main() { ...
分类:其他好文   时间:2015-05-02 20:46:48    阅读次数:200
UVa 11556 - Best Compression Ever
题目:给你n个文件,问用b+1位2进制数能否进行编号(不包括全0的编号)。 分析:简单题。直接比较n与(1 说明:使用long long防止溢出。 #include #include #include #include #include #include using namespace std; int main() { long long n,b,m; while (c...
分类:其他好文   时间:2015-05-02 20:46:22    阅读次数:177
hdu3555Bomb 数位dp
#include #include #include using namespace std ; const int maxn = 20 ; int bit[maxn] ; __int64 dp[maxn][maxn][2] ;//dp[i][j][1]第i位数为j时内有49的数量,0位不含 void init() {     memset(dp , 0 ,sizeof(dp))...
分类:其他好文   时间:2015-05-02 18:16:32    阅读次数:110
hdu 1890 Robotic Sort
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1890如下: 1 #include 2 #include 3 #include 4 #include 5 using std::sort; 6 using std::swap; 7 cons...
分类:其他好文   时间:2015-05-02 17:58:29    阅读次数:101
hdu 3555 数位dp水题 记忆化搜索做法
#include #include #include using namespace std ; const int maxn = 20; __int64 dp[maxn][3] ;//dp[i][flag] ,flag = 2,表示已经有49,flag == 1,表示没有49,这一位是4, int bit[maxn] ;    //flag == 0, 什么都没有 __int64 ...
分类:其他好文   时间:2015-05-02 16:38:34    阅读次数:125
九度1078(二叉树已知先序和中序求后序)
题目链接:点击打开链接 解题思路: 很不错的一道题。用递归的方法求解。每次对两个序列进行递归,求得左子树的先序/中序,右子树的先序/中序。把树建好后调用递归输出后序即可 完整代码: #include #include #include using namespace std; string fir , mid; typedef struct Node { ...
分类:其他好文   时间:2015-05-02 16:37:13    阅读次数:101
hdu4221 Greedy?(贪心)
真不知道为啥全是英文题。。。就不能好好的出中文的啊  啊 啊 果然看错了题意   #include #include using namespace std; struct node { long long day,end; }c[100005]; bool cmp(node x,node y) { if(x.end<y.end) return true; if(x.end==y....
分类:其他好文   时间:2015-05-02 16:34:33    阅读次数:121
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!