自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

禅境花园

http://www.xiang578.com

  • 博客(613)
  • 资源 (1)
  • 收藏
  • 关注

原创 头文件

#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>#include <queue>#include <stack>#include <set>#include <map>#include <string>#include <cmath>#inclu

2015-12-15 12:27:34 424

原创 数论基础

数论

2015-08-06 12:44:00 976

原创 vim编译c++文件设置

。。。

2015-03-29 08:56:35 3111 3

原创 4. 两个排序数组的中位数 【二分】

题目链接 两个排序数组的中位数 leetcode hard 总题解目录 xiang578/leetcode 给定两个大小为 m 和 n 的有序数组 nums1 和 nums2 。 请找出这两个有序数组的中位数。要求算法的时间复杂度为 O(log (m+n)) 。 示例 1: nums1 = [1, 3] nums2 = [2] 中位数是 2.0 示例...

2018-06-18 14:45:27 377

原创 【 Emacs-04】解决 Emacs 在 macOS iTerm2 中无法使用 Meta 键问题

参考下面链接设置 终端下emacs部分快捷键无法使用 - phodal的回答 - SegmentFault 思否

2018-04-18 21:58:33 1842

原创 【 Emacs-03】在终端运行 Emacs

前几天装了 Emacs ,发现在命令行运行 emacs 指令也只能打开 gui 版本的 Emacs。 晚上在看其他人博客时,发现输入命令 emacs -nw 就可以轻松打开终端版本了。...

2018-04-18 21:30:44 6015

原创 最后一篇博文

近来CSDN博客改版,也不会用了,所以停止博客更新。如果对我写的东西感兴趣,可以访问我的新博客 xiang578.com谢谢

2018-01-14 16:00:28 314

原创 Codeforces Round #441 (Div. 2, by Moscow Team Olympiad) D. Sorting the Coins【规律】

题目比较难读懂,读懂之后就好写了,看一下第二组样例就可以找到规律。/* ***********************************************Author :xiang578Email :[email protected] Time :Wed Nov 8 15:53:46 2017File Name :cf876d.c

2017-11-08 18:45:31 244

原创 Codeforces Round #444 (Div. 2) C. Solution for Cube【模拟】

学习一波网上简单的思路,直接判断旋转好的情况,一共六种情况。 判最后结果时至少需要四个面。/* ***********************************************Author :xiang578Email :[email protected] Time :Mon Nov 6 16:11:14 2017File Name

2017-11-06 16:36:58 265

原创 Codeforces Round #442 (Div. 2) E. Danil and a Part-time Job【线段树+dfs序】

对原来的图进行一波dfs,序列化,用线段树维护。查询就是线段树上区间查询,修改时可以用延迟标记一下。/* ***********************************************Author :xiang578Email :[email protected] Time :Mon Nov 6 14:30:42 2017File N

2017-11-06 15:42:16 280

原创 Codeforces Round #442 (Div. 2) C. Slava and tanks 【找规律】

分成三组 第一组是2 4 6 … 第二组是1 3 5 … 第三组是2 4 6 …#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#include <vector>#include <queue>#include <set>#include <map>#include <st

2017-11-06 13:46:36 242

原创 Codeforces Round #415 (Div. 2) C. Do you want a date? 【前缀和】

先把输入排个序,对于每个ai{a_i}和aj{a_j}来说,对最后的答案的贡献是 (aj−ai)∗2j−i−1{(a_j-a_i)*2^{j-i-1}} 。这样复杂度在 n2{n^2}。再化简一下式子,我们可以发现每个ai{a_i} 对于答案的贡献是 ai∗(fi−fn−i−1){a_i*(f_i-f_{n-i-1} )},其中fi=20+21+...2i{f_i=2^0+2^1+...2^i}。/

2017-11-06 13:28:52 233

原创 Codeforces Round #443 (Div. 2) C. Short Program 【模拟】

数字的范围为1-1023,所以用二进制表示需要10位。维护一个长度为10的数组a,分别代表每一位最后的值,取值一共有三种0,1和未知。 对于与操作,a数组对应位置上的数字置为0。对于或操作,a数组对应位置上的数字置为1。对于异或操作,如果a对应位置上的数字已经确定,则直接异或,否者另外用记录一下。最终答案由3种操作组成,或操作的数字是a数组中所有为1的位置表示的二进制数,与操作数是1023-a数组

2017-11-06 13:19:37 245

原创 Codeforces Round #420 (Div. 2) E. Okabe and El Psy Kongroo [矩阵快速幂]

题目无聊到求多次快速幂…#pragma comment(linker, "/STACK:102400000,102400000")#include<cstdio>#include<algorithm>#include<cmath>#include<cstring>#include<vector>#include<map>#include<string>#include<iostrea

2017-07-08 21:33:48 272

原创 [搜索] hdu1043 Eight(8思路)

思路来源:八数码的八境界境界一:广搜+map最简单的思路,从输入的字符串开始暴力广搜,用map记录到达每种状态的步骤以及是否搜索过,然后爆了内存.#include<bits/stdc++.h>using namespace std;char c[10];string s,wt="123456789";map<string,string>mp;int dx[]={0,0,-1,1};int

2017-06-02 18:04:52 358

原创 实习学习记录

6月1日双向迪杰斯特拉 1. 主要用于解决单个起点和单个终点的问题 2. 分别从起点s{s}和终点t{t}开始计算到达其他点的最短路,维护两个集合S(i){S(i)}和 T(i){T(i)},代表s{s}到i{i}的最短距离以及t{t}到i{i}的最短距离。 3. 每次选择S(i){S(i)}和 T(i){T(i)}中最小的一个项进行按dijkstra算法更新。 4. 如果发现S(i){

2017-06-01 20:04:24 445

原创 Codeforces Round #416 (Div. 2) C. Vladik and Memorable Trip 【线性DP】

对于每个数字 ai{a_i} 处理出最左的位置 Lai{L_{a_i}} 和最右的位置 Rai{R_{a_i}},然后 dpi{dp_i} 为前i个数字最大的值,对于每一个 Lai=i{L_{a_i}=i} 的位置计算出来i到MAX(Rai−Rai){i到MAX(R_{a_i-R{a_i}})} 的异或值,然后更新dp{dp},最后dpn{dp_n} 为最后的答案。#include<bits/std

2017-05-29 15:42:52 445

原创 Codeforces Round #416 (Div. 2) D. Vladik and Favorite Game【交互题+BFS】

首先要判断一下LR、DU有没有交换。一共有三种情况 1. 起点只能向下走 2. 起点只能向右走 3. 起点可以向下或者向右走之后用bfs找出一条路径,然后去输出就可以了。#include<bits/stdc++.h>using namespace std;const int N=6000;int dx[]= {0,0,-1,1};int dy[]= {1,-1,0,0};int n

2017-05-29 15:31:13 315

原创 PAT-GPLT L3-018. 森森美图【最短路+ToleftTest】

起点和终点将矩阵分成两部分,然后让你从两个部分分别求一条最短路。 判断点属于那个部分只要用ToLeftTest就可以了,大于0在直线的左边。第一次求起点到终点,第二次求终点到起点的最短路。起点和终点的分数这样会被计算两次,需要减一下。#include<bits/stdc++.h>using namespace std;int n,m,inq[120][120];double s[120][12

2017-04-21 16:09:13 2699

原创 POJ1696 Space Ant 【凸包-ToLeft-Test】

#include<map>#include<set>#include<ctime>#include<cmath>#include<queue>#include<string>#include<vector>#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>#include<function

2017-04-16 20:40:15 328

原创 2017年团体程序设计天梯赛-总决赛 L3-1. 二叉搜索树的结构

注意一下查询的值不一定都在二叉树上面#include<bits/stdc++.h>using namespace std;int n,t,cnt,f[1024],a,b,fa,fb;char s[1024];map<int,int>mp;struct node{ int n; int d; int l,r;} p[1024];void build(int now

2017-04-16 11:15:53 546

原创 2017年团体程序设计天梯赛-总决赛 L2-2. 重排链表

输入的数据可能不是一张链表的,陈越教授风格#include<bits/stdc++.h>using namespace std;struct node{ int add; int d; int next;} p[123456],p1[123456];int k,st,n,nt,m[123456],r[123456];int main(){ int a,d,t

2017-04-16 10:29:34 1316

原创 2017年团体程序设计天梯赛-总决赛 L1-6. 整除光棍

L1-6. 整除光棍当时想用java写,不过忘记Scanner怎么用了,现在用模拟重新写了一下#include<bits/stdc++.h>using namespace std;int x;int get(int c){ int k=0; for(int i=1;i<=c;i++) { k=k*10+1; k%=x; }

2017-04-16 10:21:16 1244

原创 ZOJ3952 Fibonacci Sequence Chicken Edition 【模拟】

#include<bits/stdc++.h>using namespace std;void print(int n){ for(int i=0; i<n; i++) { printf("c"); } printf("\n");}int main(){ int a[100]; int x=38; int y=5;

2017-04-10 10:13:15 689

原创 1123. Is It a Complete AVL Tree (30) 二叉搜索树

#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>#include <queue>#include <set>#include <map>#include <string>#include <math.h>#include <stdlib.h>#i

2017-03-03 15:51:38 259

原创 zoj3640 Help Me Escape 【概率DP+期望】

#include<bits/stdc++.h>using namespace std;double dp[20000+10];int t[1024],f,k,mx,c[1024];int main(){ int n; while(~scanf("%d%d",&n,&f)) { mx=0; for(int i=0;i<n;i++)

2017-02-08 11:18:27 490

原创 hdu3853 LOOPS 【概率DP+期望问题】

#include<bits/stdc++.h>using namespace std;const int N=1024;int n,m;double dp[N][N],r[N][N],d[N][N],p[N][N];int main(){ while(~scanf("%d%d",&n,&m)) { for(int i=1;i<=n;i++)

2017-02-07 19:48:45 329

原创 hdu4405 Aeroplane chess【概率DP+期望问题】

#include<bits/stdc++.h>using namespace std;const int N=1e6+5;double dp[N];int t[N],n,m;int main(){ while(cin>>n>>m) { if(!n&&!m) break; memset(t,0,sizeof(t)); for(i

2017-02-07 19:12:32 283

原创 VIJOS P1037搭建双塔 【双塔DP】

dp[i][j]: 代表合理利用前i个水晶建造两座塔,较高的塔比较低的塔高j时,较高的塔的高度。 每次转移考虑三种情况,不选用第i个,或者分别放在较高的塔上、较低的塔上。#include<bits/stdc++.h>using namespace std;int sum,n,h[1000],dp[2][5000];int main(){ while(~scanf("%d",&n))

2017-02-04 21:14:51 787

原创 Intel Code Challenge Final Round C. Ray Tracing【模拟】

#include<bits/stdc++.h>using namespace std;typedef long long ll;const ll inf=1e15;const int N=1e6+10;struct date{ int x,y,to; ll t;} p[N];int n,m,k,d,x,y;map<pair<int,int>,int>mp;int ma

2016-10-11 08:14:34 299

原创 bnu52308 We don't wanna work! 【模拟+set】

#include<bits/stdc++.h>using namespace std;typedef long long ll;const int N=1e5+10;int n,m;struct node{ int num,id; string name;}p[N];int cmp(node a,node b){ if(a.num==b.num) return

2016-10-08 22:34:51 265

原创 hdu5925 Coconuts 【离散化+bfs】

#include<bits/stdc++.h>using namespace std;typedef long long ll;const int N=1e5;struct node{ int x,y;}p[1024];int x[N],y[N],g[2048][2048],d[N],vis[2048][2048],mx,my;int dx[]={0,0,-1,1};int

2016-10-07 13:52:36 974

原创 hdu5920 Ugly Problem【贪心+高精度减法】

/* ***********************************************Author :MaltubEmail :[email protected] :htttp://www.xiang578.com************************************************ */#

2016-10-05 10:22:42 752

原创 hdu3294 Girls' research 【manacher算法】

#include<bits/stdc++.h>using namespace std;typedef long long ll;const int N=1e6+10;string t;char s[10],a[200000+10];int p[N];int main(){ while(~scanf("%s%s",s,a)) { int k=s[0]-'a

2016-09-29 10:57:02 241

原创 hdu5787 K-wolf Number【数位dp】

#include<bits/stdc++.h>using namespace std;typedef long long ll;int num[20],k;ll dp[20][2048];//dp[i][k]//i:数位,k:前面数字的状态//pos为当前处理的数位(权重表示法,也就是剩下pos+1位待填数)//have-状态;//lim-后面的数是否可以任意填,1-不可以,0-可以

2016-09-27 18:48:59 296

原创 HDU 5893 List wants to travel 【线段树+树链剖分】

#include<bits/stdc++.h>using namespace std;typedef vector<int> VI;typedef unsigned long long ull;typedef long long ll;typedef double db;const ll mod=1000000007;const int N=2e5+10;const int inf=

2016-09-22 16:42:04 396

原创 hdu3911 Black And White 【线段树+区间异或操作】

#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>#include <queue>#include <stack>#include <set>#include <map>#include <string>#include <cmath>#inclu

2016-09-20 19:36:06 661

原创 hdu5898 odd-even number 【数位DP】

#include<bits/stdc++.h>using namespace std;typedef long long ll;int num[20];ll dp[20][20][3];//dp[i][k]//i:数位//k:3种状态,0-随便填,1-必须要选奇数,2-必须要选偶数//pos为当前处理的数位(权重表示法,也就是剩下pos+1位待填数)//have-状态;//lim-

2016-09-18 21:40:29 828

原创 Codeforces Round #372 (Div. 2) C. Plus and Square Root【二分】

最简单的解法应该是第i次时,当前的值为i*(i-1),假设下一步时值为(i+1) * i,然后应该加 (i+1) * (i+1) * i-i-1次。自己的想法是假设当前为m,那么要能开方且复合题意的话,要得到的值最小应该为mi=(i+1) * k,其中要满足(mi * mi -now)%i==0,k可以通过二分来找到,还要注意一点计算过程中会超过long long 的范围,所以要避免4个数连乘,先求

2016-09-18 21:37:05 359

原创 Codeforces Round #370 (Div. 2) C. Memory and De-Evolution【dfs+想法】

刚开始想从(x,x,x)进过一些方法得到(y,y,y),但是想了好多方法都不行。后来发现反过来想比较简单从(y,y,y)开始,按照三角形的要求得到下一个为(2*y-1,y,y),然后一直这样做下去。最后当三角形边最小的长度大于x时,就可以结束了。#include<bits/stdc++.h>using namespace std;int x,y,ans1,ans;void dfs(int a,

2016-09-12 16:10:35 254

图论算法理论、实现及应用--王桂平--PPT--源代码--例图

图论算法理论、实现及应用--王桂平配套使用

2015-07-20

空空如也

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

TA关注的人

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