自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Naruto_____的专栏

hello world!

  • 博客(24)
  • 收藏
  • 关注

原创 多重背包

poj 1742#include #include #include using namespace std;const int MAXN = 100010;int n, m;bool dp[MAXN];int a[MAXN], c[MAXN];int queue[MAXN];int main() { while(~scanf("%d%d", &n, &m)) {

2015-12-22 14:44:23 346

原创 zoj 2112 (主席树)

Orz......#include using namespace std;const int MAXN = 60010;const int MAXQ = 10010;const int MAXM = 2500010;int n, m, dex;int a[MAXN], sorted[MAXN], root[MAXN], lower[MAXN], temp[MAXN];int

2015-11-09 21:36:05 646

原创 poj 2104 (主席树)

主席树模板题#include using namespace std;const int MAXN = 100010;const int MAXM = MAXN * 25;int n, m, q, dex;int a[MAXN], sorted[MAXN], root[MAXN];int T[MAXM], lson[MAXM], rson[MAXM];void Init()

2015-11-07 15:46:11 393

原创 hdu 4417(划分树)

将h值与划分树的中间值作比较,不小于中间值的话,答案加上查询区间进入左子树的个数并进入右子树,否则直接进入左子树。(注:查询区间可能为空)#include #include #include #include using namespace std;const int MAXN = 100010;int val[20][MAXN], toleft[20][MAXN];int

2015-10-24 14:54:50 507

原创 hdu 2665(划分树)

划分树模板题#include #include #include #include #include using namespace std;const int MAXN = 100010;int toleft[20][MAXN], val[20][MAXN];int sorted[MAXN];void BuildT(int tl, int tr, int i) {

2015-10-22 15:57:19 426

原创 排序背包(hdu 3466 & hdu 5501)

hdu 3466#include #include #include #include using namespace std;int a[5010];struct good { int p, q, v;};good gd[510];bool cmp(good a, good b) { return (a.p - a.q) > (b.p - b.q);}in

2015-10-11 19:27:11 488

原创 hdu 1542(扫描线)

#include #include #include #include #define MAXN 110using namespace std;struct Line { double y1, y2; double x; int flag;};Line line[MAXN * 2];struct Tree { double y1, y2; double x; in

2015-09-30 17:24:59 384

原创 hdu 5465(二维树状数组)

二维bit + 尼姆博奕#include #include #include #define Max 510using namespace std;int n, m;int a[Max][Max];int c[Max][Max];int lowbit(int x) { return x & (-x);}int sum(int x, int y) { i

2015-09-22 20:32:21 365

原创 zoj 2859(二维线段树)

给一个不作更改的矩阵,多次查询子矩阵的最小值#include #include #include #include using namespace std;const int Max = 305;int n;struct Treex { int treey[Max << 2]; void Buildy(int l, int r, int i) { if(l == r)

2015-09-22 20:14:28 589

原创 树的重心

树的重心定义为:找到一个点,其所有的子树中最大的子树节点数最少,那么这个点就是这棵树的重心,删去重心后,生成的多棵树尽可能平衡.poj 3107#include #include #include #include #include #define Max 50010using namespace std;int n;int Start[Max], N

2015-09-10 15:27:23 417

原创 归并排序

#include #define Max 100int min(int a, int b) { return a < b ? a : b;}void merge_array(int *array, int *new_array, int first, int last) { int mid = (first + last) / 2; int a = first; int b =

2015-09-09 20:49:23 390

原创 快速排序

#include #define Max 100int get_prvot(int a, int b) { return (a + b) / 2;}void q_sort(int left, int right, int *array) { if(left >= right) return ; int a = left; int b = right; int prvot

2015-09-09 20:47:44 320

原创 linux终端翻译神器

#! /usr/bin/pythonimport re;import urllib;import urllib2;import sys;def debug(): xml = open("word.xml").read(); print get_text(xml); print get_elements_by_path(xml, "custom-translation/content

2015-08-10 16:03:04 2387

原创 hdu 5358(尺取法)

#include #include #include #include #define Max 100010using namespace std;typedef long long LL;LL sum[Max];LL p[50];int n, con;void Init() { for(LL i = 1; i <= 1e10; i *= 2) p[con++] =

2015-08-09 11:02:19 532

原创 Manacher(回文字符串)

void manacher() { int id, mx = 0; //mx为已知回文字符串触及到最远的下标 id为mx对应的回文中心 for(int i = 1; i < newlen; i++) { if(mx >= i) p[i] = min(p[2 * id - i], mx - i + 1); for(; news

2015-08-02 15:16:15 421

原创 vim配置

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 显示相关  """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

2015-06-25 10:46:20 449

转载 半平面交

首先解决问题:什么是半平面? 顾名思义,半平面就是指平面的一半,我们知道,一条直线可以将平面分为两个部分,那么这两个部分就叫做两个半平面。然后,半平面怎么表示呢? 二维坐标系下,直线可以表示为ax + by + c = 0,那么两个半平面则可以表示为ax + by + c >= 0 和ax + by + c 还有,半平面的交是神马玩意? 其实就是一个方程组,让你画出满足若干个式子的

2015-05-07 10:22:58 845

原创 poj 2411(状态压缩dp)

#include #include #include using namespace std;int state[150];long long dp[12][1 << 11];int num[12];int n, m;int p;bool Check(int x) { int i; bool flag = 1; for(i = 0; i < m; i++) if(x

2015-05-05 20:24:44 472

原创 poj 3254(状态压缩dp)

#include #include #include #define MOD 100000000using namespace std;int n, m;int p;int state[1 << 12], pow[15];int Map[15];int dp[15][1 << 12];void Init() { int i; p = 0; pow[0] = 1; f

2015-05-03 20:31:32 436

原创 hdu 3001(状态压缩dp)

#include #include #include #define Max1 10 #define Max2 59049 // 3^10#define INF 0x3f3f3f3fusing namespace std;/*由于每个点可经过两次 用三进制数表示状态 例10020(三进制)表示经过点2两次点1一次其余点都没经过*/int n, m, ans;int Pow[M

2015-05-02 21:30:44 523

原创 tyvj 1684(状态压缩dp)

#include #include #include using namespace std;int n, m, p;int Map[110];int dp[110][65][65];int s[110], num[110];inline int max(int a, int b) { return a > b ? a : b;}bool check(int x) {

2015-05-02 14:13:21 455

原创 hoj 2662(状态压缩dp)

#include #include #include #define Max 1<<9using namespace std;typedef long long LL;LL n, m, k;LL p;LL status[Max], num[Max];LL dp[81][21][Max];bool Check(LL x) { if(x & (x << 1)) retu

2015-05-02 14:07:57 1462

原创 线段树

void build_tree(int left, int right, int i) { if(left == right) { int val; scanf("%d", &val); n[i].nmax = n[i].nmin = val; return ; } int mid = (left + right) / 2; build_tree(left, mid, i

2014-11-14 21:24:01 391

原创 nyoj 289(0-1背包)

苹果时间限制:3000 ms  |  内存限制:65535 KB难度:3描述ctest有n个苹果,要将它放入容量为v的背包。给出第i个苹果的大小和价钱,求出能放入背包的苹果的总价钱最大值。输入有多组测试数据,每组测试数据第一行为2个正整数,分别代表苹果的个数n和背包的容量v,n、v同时为0时结束测试,此时不输出。接下来的n行,每行2个

2014-11-08 14:20:23 530 1

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除