自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

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

原创 scala 完成全排列和归并排序

def sort(A: Array[Int]) { if(A.length > 1){ val p = A.take(A.length/2) val q = A.takeRight(A.length - A.length/2) sort(p); sort(q) var i = 0; var j = 0 while(i < p.length && j < q.length){

2017-01-05 00:20:40 350

原创 不可变集合的重要性

这几天看scala(其实什么都不会),一直很好奇不可变集合到底有什么优势,然后就从某牛那里得到了下面4条1、对不可靠的客户代码库来说,它使用安全,可以在未受信任的类库中安全的使用这些对象。感觉这句话好有说服力2、线程安全的:immutable对象在多线程下安全,没有竞态条件。可以有效避免错误,很好的代码规范3、不需要支持可变性, 可以尽量节省空间和时间的开销. 所有的不可变集合

2016-12-21 19:50:45 566

原创 常单向链表

#include #include using namespace std;templateclass List{public: struct Node{ const T data; const Node* const next; Node(const T& _d, const Node* const _n):data(_d), n

2016-12-21 19:17:18 194

原创 给vim配置scala的语法高亮显示

在命令行下执行下面这句话mkdir -p ~/.vim/{ftdetect,indent,syntax} && for d in ftdetect indent syntax ; do curl -o ~/.vim/$d/scala.vim https://raw.githubusercontent.com/gchen/scala.vim/master/scala.vim; done

2016-12-19 14:07:43 285

原创 C语言读取上下左右键

#include #include int main(){int ch;//while()while((ch = getch())!= 0x1B){//printf("%c\n", ch);switch (ch){case 0xE0:switch(ch = getch()){case 72: puts("U");break;case 80: puts("

2016-12-13 23:11:41 5649

原创 go语言实现生产者与消费者问题

package mainimport "fmt"import "time"var quit chan int // 只开一个信道var s[5] intvar sum intfunc create(id int) { for ;;{ if sum > 15{ //15 + 5(5个线程) = 20 (总的生产个数) quit <- 0

2016-12-10 21:45:10 399

原创 哈希集合

#include #include #include #include using namespace std;const int hash_prime_num = 15;const unsigned int _stl_prime[] = { 2, 5, 11, 23, 53, 97, 193, 389, 769, 1543, 3079, 6151, 122

2016-12-01 16:52:20 273

原创 用哈希表实现简陋的无序set

#include #include #include #include using namespace std;const int hash_prime_num = 15;const unsigned int _stl_prime[] = { 2, 5, 11, 23, 53, 97, 193, 389, 769, 1543, 3079, 6151, 122

2016-11-30 22:38:15 244

原创 STL::unordered_map(无序map)

C++的map是重载了"class templateunordered_map template < class Key, //unordered_map::key_type key类型 class T, //

2016-11-28 17:43:11 250

原创 ubuntu下自己建立动态链接库

新建一个目录 Hello , 然后进入(其实并不需要)dsp@dsp-INVALID:~$ mkdir Hellodsp@dsp-INVALID:~$ cd Hello建立文件 Hello.h #ifndef _HELLO_H_ #define _HELLO_H_ void Hello(const char* name); #endif建立文件 Hello.

2016-11-26 11:30:45 587

原创 STL_简易pair与trio

pair:该数据结构里有两种数据类型trio:该数据结构里有三种数据类型test.cpp如下#include #include #include "utility.h"using namespace std;typedef PairPair_ic;typedef TrioTrio_iic;Pair_ic p0;Trio_iic t0;class Int{ in

2016-11-20 11:55:54 195

原创 STL_迭代器_简单双向链表

#include #include using namespace std;templateclass List{public: struct node{ T data; node(){ next = prior = NULL;} node *next, *prior; };private: node *head,

2016-11-19 20:40:05 164

原创 STL_迭代器_单向链表

#include #include #include using namespace std;templateclass List{public: struct node{ T data; node* next; node(){ next = NULL;} }; node *head, *tail; List(){ head = new node, tail = N

2016-11-19 10:00:22 209

原创 STL_迭代器_不可变长度数组类

#include using namespace std;templateclass Arry{T *p;const int length;public:Arry(int _n):length(_n){ p =new T[length];}T* begin(){ return p;}T* end(){ return p+length;}int size()

2016-11-18 21:08:26 151

原创 三道水题

POJ 3737 UmBasketella #include #include using namespace std;const double eps = 1e-8;#define PI acos(-1.0)double S;double GetH(double r){ double a = S/PI/r - r; a = a*a - r*r; retu

2016-10-27 19:52:52 177

原创 树状数组

HDU 1166 敌兵布阵 最简单的树状数组点更新,区间查询#include#includeusing namespace std;int c[100001];int n, m;void add(int k, int s){ for(int i = k; i <= n; i += i & (-i)){ c[i] += s; }}int sum(int k){ i

2016-10-23 13:31:21 171

原创 弱校联盟 10.7 D(poj3734)

打表找规律即可1 = 1*26 = 2*320 = 4*572 = 8*9...#include #include using namespace std;const int MOD = 10007;int fp(int a, int b){ int ans = 1; a %= MOD; while(b) { if(

2016-10-07 16:29:53 167

原创 弱校联盟 10.7 M (poj3600)

先暴力一下列,行就不能再暴力了,不然会超时。对于行,可以一行一行比较,因为暴力了之后两者列数是一样的,比较行是否一样的时候,我使用了状态压缩#include #include #include using namespace std;const int M = 202;int a[M][M], b[M][M];int na, nb, ma, mb;bool vis[M];int c

2016-10-07 16:25:19 163

原创 弱校联盟 10.7 G (poj3737)

应该是有公式的,本弱不会,用的三分法。这是个单峰函数,体积先随着半径的增长而变大,然后变小。此代码在poj上选择用C++提交,不要用G++

2016-10-07 16:18:10 131

原创 弱校联盟 10.7

#include #include using namespace std;const double eps = 1e-8;#define PI acos(-1.0)double S;double GetH(double r){ double a = S/PI/r - r; a = a*a - r*r; return sqrt(a);}double GetV

2016-10-07 16:14:39 120

原创 弱校联盟 10.7 G题 (poj 3737)

应该是可以直接推出公式的,本弱不会,就写了一个三分法。看题意就应该能知道体积先随着半径的增长而变大,然后变小,是但峰的#include #include using namespace std;const double eps = 1e-8;#define PI acos(-1.0)double S;double GetH(double r){ double a = S

2016-10-07 16:09:11 95

转载 国家集训队论文分类整理

国家集训队论文分类整理距离ACM/ICPC的时间越来越少了,选择性地看一些集训队论文是很有必要的。(在此给已经看过所有论文的神牛跪了= =)所以,我在此整理了一下,供大家参考。组合数学计数与统计2001 - 符文杰:《Pólya原理及其应用》2003 - 许智磊:《浅谈补集转化思想在统计问题中的应用》2007 -

2016-09-27 20:44:38 190

原创 POJ 3311 Hie with the Pie

#include #include #include #include using namespace std;const int M = 1<<12;typedef long long LL;int dp[M][12];int a[12][12];//S是一个点的集合,dp[S][i]代表当遍历S这些点且最后通过i回到原点的最小路径int main(){ //freo

2016-09-16 12:55:53 111

原创 UVA 10692 Huge Mods 指数循环节

#include #include #include #include using namespace std;typedef long long LL;int a[120], n;LL u, m;LL phi(LL n){ LL ans = n; for(int i = 2; i*i <= n; i++){ if(n%i == 0){

2016-08-11 11:26:20 182

原创 UVA 11987 Almost Union-Find 虚拟跟节点的并查集

#include #include using namespace std;const int M = 1e5 +20;int Rank[M*2], sum[M*2], p[M*2];int find(int x){ if(x == p[x]) return x; return p[x] = find(p[x]);}int main(){ int x,

2016-08-10 10:01:56 118

原创 HDU 2841 Visible Trees (容斥原理)

#include #include #include #include using namespace std;struct node{ int x, y; node(int _x = 0, int _y = 0):x(_x), y(_y){}};const int M = 120100;vectorbuf;vectorv;int m;bool fact(int m){

2016-08-07 12:56:20 135

原创 UVA 437 巴比伦塔

#include #include #include #include using namespace std;struct node{ int a[4]; node(){} void Sort(){sort(a, a+3);}}p[1200];bool g[120][4][120][4];bool vis[120][4];int n, dp[120][4];bool

2016-08-07 11:39:57 173

原创 UVA - 11584 Partitioning by Palindromes

#include #include #include using namespace std;const int M = 1200;char Ma[M*2];int Mp[M*2];void Manacher(char s[], int len){//预处理 int l = 0; Ma[l++] = '$'; Ma[l++] = '#'; for(int i = 0; i

2016-08-07 11:36:01 133

原创 UVA 12563 Jin Ge Jin Qu hao

#include #include using namespace std;const int M = 10000;struct node{ int x, y; node(int _x = 0, int _y = 0):x(_x), y(_y){}};int v[M];node dp[M];int main(){ int s, t, cas = 1, n; cin >>

2016-08-06 16:00:35 150

原创 light oj 1224

/*每个节点经过的次数乘上该节点到跟节 点的距离,这些数中的最大值即为答案 */#include #include #include #include using namespace std;struct node{ node* next[4]; int count, num; node(){ for(int i = 0; i < 4; i++) next[i] =

2016-07-27 20:46:16 131

原创 1190 - Sleepwalking 判断点是否在多边形内

/* 射线法,把多边形理解为一个有围墙的大院,一个人从院外越过一道墙,他就进了大院,如果他再越过一道墙,就出了大院。无论大院的形状如何奇特,只要从院外越过奇数道围墙,他就在院内,越过偶数道围墙就在院外。所以,判断一点是否在多边形内或多边形外,只要从这点起,作一条射线。为了避免端点情况,多运行了几次 */#include using namespace std;struct p

2016-07-25 14:48:10 154

原创 1292 - Laser Shot

//这些运算符重载看起来有点乱//核心思想是极角排序 #include using namespace std;struct point{ int x, y; friend bool operator <(const point& p1,const point& p2); friend bool operator ==(const point& p1, const point& p2

2016-07-24 19:10:47 144

原创 light oj 1137 - Expanding Rods

#include #include #define PI (M_PI)#define u (PI-2*atan(x/mid))#define v 2*((x/(tan(u)))+mid)*uconst double eps = 1e-11;int main(){ double l, n, c, x, y, r, L; double low, high, mid; int t

2016-07-24 18:13:23 154

原创 Light oj 1418 Trees on My Island

//pick 定理#include using namespace std;typedef long long LL;LL area, ans;struct point{ LL x, y;};point p[12000];int main(){ int i, t, cas = 1, n; LL x1, y1, x2, y2, u, x, y; cin >> t; wh

2016-07-24 16:20:16 113

原创 圆和矩形面积交

//light oj 1130 - Intersection between Circle and Rectangle #pragma comment(linker, "/STACK:102400000,102400000") #include #include #include #include #include #include #include

2016-07-24 16:18:38 788

原创 light oj 1130 - Intersection between Circle and Rectangle

#pragma comment(linker, "/STACK:102400000,102400000") #include #include #include #include #include #include #include #include #include #include #include #include

2016-07-24 16:17:07 291

原创 light oj 1062 - Crossed Ladders

#include #include #include using namespace std;double epx = 1e-11;int main(){ double a, b, x, y, u, low, heigh, mid, v, c; int t, cas = 1; char str[3]; scanf("%d",&t); while(t--) { scanf

2016-07-24 12:38:06 152

原创 light oj 1056 Olympics

#include #include double epx = 1e-11;int main(){ double a, b, x, y, u, low, heigh, mid, v; int t, cas = 1; char str[3]; scanf("%d",&t); while(t--) { scanf("%lf%s%lf",&x,str,&y);//吸收冒号 u

2016-07-24 12:10:36 140

原创 hdu 5727 Necklace 二分图匹配模板加上暴力枚举

#include #include #include #include using namespace std;struct node{ int x, y;};vectorbuf;int n, m, a[12], b[20], g[12][12], v[12];int linker[12];bool used[12];bool dfs(int u){ for(int

2016-07-23 15:02:58 130

原创 hdu 5738 Eureka

#include #include #include using namespace std;long long N = 1e+9 +7 , Pow[1200];struct point{ long long x, y; friend bool operator <(point& a, point& b){ if(a.y == b.y) return a.x < b.x; r

2016-07-22 14:49:51 160

空空如也

空空如也

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

TA关注的人

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