-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
553 lines (371 loc) · 30.3 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>pakchoi</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="description">
<meta property="og:type" content="website">
<meta property="og:title" content="pakchoi">
<meta property="og:url" content="http://pakchoi.github.io/index.html">
<meta property="og:site_name" content="pakchoi">
<meta property="og:description">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="pakchoi">
<meta name="twitter:description">
<meta name="twitter:creator" content="@pakchoi">
<link rel="publisher" href="pakchoi">
<link rel="alternative" href="/atom.xml" title="pakchoi" type="application/atom+xml">
<link rel="icon" href="/favicon.png">
<link rel="stylesheet" href="/css/style.css" type="text/css">
<!--[if lt IE 9]><script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7/html5shiv.min.js"></script><![endif]-->
<!-- Google Analytics -->
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'pakchoi', 'auto');
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->
</head>
<body>
<div id="container">
<div id="wrap">
<header id="header">
<div id="banner"></div>
<div id="header-outer" class="outer">
<div id="header-title" class="inner">
<h1 id="logo-wrap">
<a href="/" id="logo">pakchoi</a>
</h1>
<h2 id="subtitle-wrap">
<a href="/" id="subtitle">在前行中领悟</a>
</h2>
</div>
<div id="header-inner" class="inner">
<nav id="main-nav">
<a id="main-nav-toggle" class="nav-icon"></a>
<a class="main-nav-link" href="/">Home</a>
<a class="main-nav-link" href="/archives">Archives</a>
<a class="main-nav-link" href="//github.com/pakchoi">Github</a>
</nav>
<nav id="sub-nav">
<a id="nav-search-btn" class="nav-icon" title="Search"></a>
</nav>
<div id="search-form-wrap">
<form action="http://www.baidu.com/baidu" method="get" accept-charset="utf-8" class="search-form">
<input type="search" name="word" maxlength="20" class="search-form-input" placeholder="Search">
<input type="submit" value="" class="search-form-submit">
<input name=tn type=hidden value="bds">
<input name=cl type=hidden value="3">
<input name=ct type=hidden value="2097152">
<input type="hidden" name="si" value="pakchoi.github.io">
</form>
</div>
</div>
</div>
</header>
<div class="outer">
<section id="main">
<article id="post-开新坑" class="article article-type-post" itemscope itemprop="blogPost">
<div class="article-meta">
<a href="/2016/06/29/开新坑/" class="article-date">
<time datetime="2016-06-28T21:16:50.000Z" itemprop="datePublished">2016-06-28</time>
</a>
<div class="article-category">
<a class="article-category-link" href="/categories/Talk/">Talk</a>
</div>
</div>
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2016/06/29/开新坑/">开新坑</a>
</h1>
</header>
<div class="article-entry" itemprop="articleBody">
<h2 id="刷一发存在感">刷一发存在感</h2><p>好久没写博客了:D 学校里混了一年,实现是混不下去了,只好出来实习,结果发现自己offer烂的一笔。。。(果然学渣是没出路的吗。。)<br>今天就是标记,改天发发些干货~ ~<br><img src="http://7xn7av.com1.z0.glb.clouddn.com/QQ%E5%9B%BE%E7%89%8720160613134842.png" alt=""></p>
</div>
<footer class="article-footer">
<a data-url="http://pakchoi.github.io/2016/06/29/开新坑/" data-id="cipzhw086000700w1fkfap9z8" class="article-share-link">Share</a>
<a href="http://pakchoi.github.io/2016/06/29/开新坑/#ds-thread" class="article-comment-link">Comments</a>
</footer>
</div>
</article>
<article id="post-求最长等差数列" class="article article-type-post" itemscope itemprop="blogPost">
<div class="article-meta">
<a href="/2015/07/01/求最长等差数列/" class="article-date">
<time datetime="2015-07-01T10:27:07.000Z" itemprop="datePublished">2015-07-01</time>
</a>
<div class="article-category">
<a class="article-category-link" href="/categories/AlgoProblem/">AlgoProblem</a>►<a class="article-category-link" href="/categories/AlgoProblem/Basic/">Basic</a>
</div>
</div>
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2015/07/01/求最长等差数列/">求最长等差数列</a>
</h1>
</header>
<div class="article-entry" itemprop="articleBody">
<h2 id="最长等差数列">最长等差数列</h2><p>最长连续子序列 longest consecutive sequence 问题的升级版<br>,大家一定很熟LCS问题的求解方法,甚至他的单调队列优化版本(栈优化)。</p>
<p>这里我们将讨论其变形版:给出一系列的随机的整数数列。要求在$O(n^2)$的时间复杂度内求解出一个最长的子序列并且为等差数列。</p>
<p>这里需要注意的是题目描述里并没有说明是输出等差数列的长度还是等差数列本身。</p>
<p>这其实也是一个被别人研究过的问题,我这里只是给出这一问题的简单总结</p>
<ul>
<li>论文链接 -> <a href="http://jeffe.cs.illinois.edu/pubs/pdf/arith.pdf" target="_blank" rel="external">Jeff Erickson-Finding Longest Arithmetic Progressions</a></li>
</ul>
<h2 id="一个观点">一个观点</h2><h3 id="方法一">方法一</h3><p>一个比较简单粗暴的方法就是枚举每两个数列项,在哈希表中维护[num, d]状态的个数,记录所有可能出现的等差数列。</p>
<h4 id="伪代码如下:">伪代码如下:</h4><figure class="highlight stylus"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">for</span> <span class="tag">i</span> <span class="keyword">in</span> <span class="function"><span class="title">range</span><span class="params">(n-<span class="number">1</span>, <span class="number">0</span>)</span></span></span><br><span class="line"> <span class="keyword">for</span> j <span class="keyword">in</span> <span class="function"><span class="title">range</span><span class="params">(i+<span class="number">1</span>, n-<span class="number">1</span>)</span></span></span><br><span class="line"> d = num[j] - num[i] #数列差</span><br><span class="line"> HASH[num[i], d] = HASH[num[j], d] + <span class="number">1</span></span><br></pre></td></tr></table></figure>
<p>显然下面的描述也是等效的:</p>
<figure class="highlight stylus"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">for</span> <span class="tag">i</span> <span class="keyword">in</span> <span class="function"><span class="title">range</span><span class="params">(<span class="number">0</span>, n-<span class="number">1</span>)</span></span></span><br><span class="line"> <span class="keyword">for</span> j <span class="keyword">in</span> <span class="function"><span class="title">range</span><span class="params">(i+<span class="number">1</span>, n-<span class="number">1</span>)</span></span></span><br><span class="line"> d = num[j] - num[i] #数列差</span><br><span class="line"> HASH[num[j], d] = HASH[num[i], d] + <span class="number">1</span></span><br></pre></td></tr></table></figure>
<h4 id="C++实现如下:">C++实现如下:</h4><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">(<span class="keyword">int</span> argc, <span class="keyword">char</span> <span class="keyword">const</span>* argv[])</span> </span>{</span><br><span class="line"> <span class="built_in">unordered_map</span><pair<<span class="keyword">int</span>, <span class="keyword">int</span>>, <span class="keyword">int</span>> HASH1;</span><br><span class="line"> <span class="keyword">int</span> N;</span><br><span class="line"> <span class="keyword">int</span> d;</span><br><span class="line"> <span class="built_in">cin</span> >> N;</span><br><span class="line"> <span class="keyword">int</span> num[N];</span><br><span class="line"> <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>; i < N; i++) {</span><br><span class="line"> <span class="built_in">cin</span> >> num[i];</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="keyword">for</span> (<span class="keyword">int</span> i = N-<span class="number">1</span>; i >= <span class="number">0</span>; i--) {</span><br><span class="line"> <span class="keyword">for</span> (<span class="keyword">int</span> j = i+<span class="number">1</span>; j < N; j++) {</span><br><span class="line"> d = num[j] - num[i];</span><br><span class="line"> HASH1[mp(num[i], d)] = HASH1[mp(num[j], d)] + <span class="number">1</span>;</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="keyword">int</span> MAX = INT_MIN;</span><br><span class="line"> <span class="keyword">for</span> (<span class="keyword">auto</span> &a : HASH1) {</span><br><span class="line"> DBN(a.second);</span><br><span class="line"> <span class="keyword">if</span> (MAX < a.second) {</span><br><span class="line"> MAX = a.second;</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> <span class="built_in">printf</span>(<span class="string">"%d\n"</span>, MAX+<span class="number">1</span>);</span><br><span class="line"> <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>当然如果是自己编写的哈希表效率会更好些。</p>
<h3 id="方法二">方法二</h3><p>这里给出另一个dp的解法,用dp(i,j)表示第i项与第j项构成的等差数列的数量。</p>
<h4 id="C++实现如下:-1">C++实现如下:</h4><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br></pre></td><td class="code"><pre><span class="line"><span class="preprocessor">#<span class="keyword">define</span> MAX_N 10001</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">(<span class="keyword">int</span> argc, <span class="keyword">char</span> <span class="keyword">const</span>* argv[])</span> </span>{</span><br><span class="line"> <span class="keyword">int</span> N; <span class="keyword">int</span> d; <span class="keyword">int</span> pre;</span><br><span class="line"> <span class="built_in">unordered_map</span><<span class="keyword">int</span>, <span class="keyword">int</span>> eleMap;</span><br><span class="line"> <span class="keyword">int</span> dp[MAX_N][MAX_N];</span><br><span class="line"> <span class="built_in">cin</span> >> N;</span><br><span class="line"> <span class="keyword">int</span> num[N];</span><br><span class="line"> <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>; i < N; i++) {</span><br><span class="line"> <span class="built_in">cin</span> >> num[i];</span><br><span class="line"> eleMap[num[i]] = i; <span class="comment">// 逆映射</span></span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="keyword">int</span> MAX = INT_MIN;</span><br><span class="line"> <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>; i < N; i++) {</span><br><span class="line"> <span class="keyword">for</span> (<span class="keyword">int</span> j = i+<span class="number">1</span>; j < N; j++) {</span><br><span class="line"> d = num[j] - num[i];</span><br><span class="line"> pre = num[i] - d;</span><br><span class="line"> <span class="keyword">auto</span> it = eleMap.find(pre);</span><br><span class="line"> <span class="keyword">if</span> (it != eleMap.end()) {</span><br><span class="line"> dp[i][j] = dp[it->second][i] + <span class="number">1</span>;</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">else</span> {</span><br><span class="line"> dp[i][j] = <span class="number">2</span>;</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">if</span> (dp[i][j] > MAX) {</span><br><span class="line"> MAX = dp[i][j];</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> <span class="built_in">printf</span>(<span class="string">"%d\n"</span>, MAX);</span><br><span class="line"></span><br><span class="line"> <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<h2 id="另一个观点">另一个观点</h2><p>如果我们把问题条件改一下,输出不是子序列,而是一个子集,这个自己可以构成等差数列,那么这个问题怎么求解?其实我们只要先排序就好了。</p>
</div>
<footer class="article-footer">
<a data-url="http://pakchoi.github.io/2015/07/01/求最长等差数列/" data-id="cipzhw07b000100w1c1vf66uz" class="article-share-link">Share</a>
<a href="http://pakchoi.github.io/2015/07/01/求最长等差数列/#ds-thread" class="article-comment-link">Comments</a>
</footer>
</div>
</article>
<article id="post-n个球放到m个盒子里" class="article article-type-post" itemscope itemprop="blogPost">
<div class="article-meta">
<a href="/2015/05/19/n个球放到m个盒子里/" class="article-date">
<time datetime="2015-05-19T10:04:46.000Z" itemprop="datePublished">2015-05-19</time>
</a>
<div class="article-category">
<a class="article-category-link" href="/categories/Math/">Math</a>►<a class="article-category-link" href="/categories/Math/Combinatorics/">Combinatorics</a>
</div>
</div>
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2015/05/19/n个球放到m个盒子里/">n个球放到m个盒子里</a>
</h1>
</header>
<div class="article-entry" itemprop="articleBody">
<h2 id="很有意思的一类组合题">很有意思的一类组合题</h2><p>n个球放到m个盒子里,根据球和盒子是否有区别以及是否允许有空盒有${ 2 } ^{ 3 }=8$种放球问题:求如下问题的放球方案数</p>
<ul>
<li>1) n个球有区别,m个盒子有区别,允许有空盒</li>
<li>${ m }^{ n }$</li>
<li>2) n个球有区别,m个盒子有区别,不允许有空盒</li>
<li>$m!S(n,m)$</li>
<li>3) n个球有区别,m个盒子无区别,允许有空盒</li>
<li>$ \begin{cases} S(n,1)+S(n,2)+…+S(n,m),\quad m\le n ; \ S(n,1)+S(n,2)+…+S(n,n),\quad m>n \end{cases} $</li>
<li>4) n个球有区别,m个盒子无区别,不允许有空盒</li>
<li>$S(n,m)$</li>
<li>5) n个球无区别,m个盒子有区别,允许有空盒</li>
<li>$C(n+m-1,n)$</li>
<li>6) n个球无区别,m个盒子有区别,不允许有空盒</li>
<li>$C(n-1,m-1)$</li>
<li>7) n个球无区别,m个盒子无区别,允许有空盒</li>
<li>$G(x)=\frac { 1 }{ (1-x)(1-{ x }^{ 2 })…(1-{ x }^{ m }) } $的$x^n$项的系数</li>
<li>8) n个球无区别,m个盒子无区别,不允许有空盒</li>
<li>$G(x)=\frac { x^m }{ (1-x)(1-{ x }^{ 2 })…(1-{ x }^{ m }) } $的$x^n$项的系数</li>
</ul>
<blockquote>
<p>注:</p>
<blockquote>
<p>S(n,m)为第二类斯特林数<br>G(x)为母函数<br>C(n+m-1,n)为多重组合</p>
</blockquote>
</blockquote>
</div>
<footer class="article-footer">
<a data-url="http://pakchoi.github.io/2015/05/19/n个球放到m个盒子里/" data-id="cipzhw086000a00w17f5qptf8" class="article-share-link">Share</a>
<a href="http://pakchoi.github.io/2015/05/19/n个球放到m个盒子里/#ds-thread" class="article-comment-link">Comments</a>
</footer>
</div>
</article>
<article id="post-Minkouski距离" class="article article-type-post" itemscope itemprop="blogPost">
<div class="article-meta">
<a href="/2015/05/14/Minkouski距离/" class="article-date">
<time datetime="2015-05-13T21:47:11.000Z" itemprop="datePublished">2015-05-13</time>
</a>
<div class="article-category">
<a class="article-category-link" href="/categories/Math/">Math</a>►<a class="article-category-link" href="/categories/Math/Geometry/">Geometry</a>
</div>
</div>
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2015/05/14/Minkouski距离/">Minkouski距离</a>
</h1>
</header>
<div class="article-entry" itemprop="articleBody">
<h3 id="最近看书的时候注意到了一个问题:Minkouski距离">最近看书的时候注意到了一个问题:Minkouski距离</h3><p>$ d(i, j) = \sqrt [ p ]{ { ({ x }_{ i1 }-{ x }_{ j1 }) }^{ p }+{ ({ x }_{ i2 }-{ x }_{ j2 }) }^{ p }+…+{ ({ x }_{ il }-{ x }_{ jl }) }^{ p } } $</p>
<h4 id="其有三个属性:">其有三个属性:</h4><ul>
<li>Positivity : 必然为正数</li>
<li>Symmetry 对称性 : $p_1$与$p_2$相互距离相等</li>
<li>Triangle Inequality : 对于任意$p_i$、$p_j$、$p_k$,$d(i,j)\le d(i,k)+d(k,j)$</li>
</ul>
<h4 id="Minkouski_ditance还可以分为:">Minkouski ditance还可以分为:</h4><ul>
<li>p = 1 , Manhattan (or city block) distance 曼哈顿距离</li>
<li><ul>
<li>E.g. the Hamming distance: 可以使用奇偶剪枝<br>$ d(i, j) = { \left| { x }_ { i1 }-{ x }_ { j1 } \right| +\left| { x }_ { i2 }-{ x }_ { j2 } \right| +…+\left| { x }_ { i3 }-{ x }_ { j3 } \right| } $</li>
</ul>
</li>
<li><p>p = 2 , Euclidean distance 欧几里得距离<br>$ d(i, j) = \sqrt{ { ({ x }_{ i1 }-{ x }_{ j1 }) }^{ 2 }+{ ({ x }_{ i2 }-{ x }_{ j2 }) }^{ 2 }+…+{ ({ x }_{ il }-{ x }_{ jl }) }^{ 2 } } $</p>
</li>
<li>p->oo , supremum distance 切比雪夫距离(两点各座标数值差绝对值的最大值)<br>$d(i,j)={ max(\left| { x }_ { i1 }-{ x }_ { j1 } \right| ,\left| { x }_ { i2 }-{ x }_ { j2 } \right| ,…,\left| { x }_ { i3 }-{ x }_ { j3 } \right| })$</li>
</ul>
<h4 id="距离的定义可以直接影响一些问题:">距离的定义可以直接影响一些问题:</h4><ul>
<li>比如A*和IDA*启发函数的设计。。</li>
<li>比如描述两组数据的相似度,或者说是两组状态的相似度。。</li>
<li>比如k-means算法中距离的衡量的标准。。</li>
<li>比如knn算法中距离。。</li>
<li>。。。。。。</li>
</ul>
</div>
<footer class="article-footer">
<a data-url="http://pakchoi.github.io/2015/05/14/Minkouski距离/" data-id="cipzhw086000k00w1gxqvo14o" class="article-share-link">Share</a>
<a href="http://pakchoi.github.io/2015/05/14/Minkouski距离/#ds-thread" class="article-comment-link">Comments</a>
</footer>
</div>
</article>
<article id="post-homebrew滚动更新的问题" class="article article-type-post" itemscope itemprop="blogPost">
<div class="article-meta">
<a href="/2015/05/08/homebrew滚动更新的问题/" class="article-date">
<time datetime="2015-05-07T21:18:39.000Z" itemprop="datePublished">2015-05-07</time>
</a>
<div class="article-category">
<a class="article-category-link" href="/categories/C/">C++</a>►<a class="article-category-link" href="/categories/C/etc/">etc.</a>
</div>
</div>
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2015/05/08/homebrew滚动更新的问题/">Homebrew滚动更新的问题</a>
</h1>
</header>
<div class="article-entry" itemprop="articleBody">
<a id="more"></a>
<p>最近遇到一个很郁闷的事情,就是本来能运行的项目突然就crash了,郁闷之余发现是一个软件的版本太高了(囧)。那为啥以前就没事呢?再思考一下估计是自己写的滚动更新的脚本的毛病,本来是想省事的却反而弄巧成茁。。。</p>
<p>具体点今天的问题就是opencv的libopencv_highgui.2.4.dylib,所依赖的libImath-2_1.11.dylib找不到了,那libImath是啥呢?一查居然是一个叫做ilmbase的软件的动态库文件。。。</p>
<p>那既然知道了问题所在,解决方法就有了,很简单就是指定版本重装ilmbase。</p>
<p>这里再给个brew的小技巧:<br>brew pin ilmbase<br>brew pin openexr<br>上面两个命令的意思就是说固定软件版本,很简单易用吧~~</p>
<p>homebrew的ruby包:</p>
<ul>
<li><a href="https://raw.githubusercontent.com/Homebrew/homebrew/2482d6e77ffcf2da68d11846dd8686a842286ac3/Library/Formula/ilmbase.rb" target="_blank" rel="external">ilmbase.rb</a></li>
<li><a href="https://raw.githubusercontent.com/Homebrew/homebrew/22076e28a72e7d4c028131bf7acb522f6505738f/Library/Formula/openexr.rb" target="_blank" rel="external">openexr.rb</a></li>
</ul>
</div>
<footer class="article-footer">
<a data-url="http://pakchoi.github.io/2015/05/08/homebrew滚动更新的问题/" data-id="cipzhw086000f00w1msw35lq2" class="article-share-link">Share</a>
<a href="http://pakchoi.github.io/2015/05/08/homebrew滚动更新的问题/#ds-thread" class="article-comment-link">Comments</a>
</footer>
</div>
</article>
<nav id="page-nav">
<span class="page-number current">1</span><a class="page-number" href="/page/2/">2</a><a class="extend next" rel="next" href="/page/2/">Next »</a>
</nav>
</section>
<aside id="sidebar">
<div class="widget-wrap">
<h3 class="widget-title">Categories</h3>
<div class="widget">
<ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/AlgoProblem/">AlgoProblem</a><span class="category-list-count">1</span><ul class="category-list-child"><li class="category-list-item"><a class="category-list-link" href="/categories/AlgoProblem/Basic/">Basic</a><span class="category-list-count">1</span></li></ul></li><li class="category-list-item"><a class="category-list-link" href="/categories/C/">C++</a><span class="category-list-count">1</span><ul class="category-list-child"><li class="category-list-item"><a class="category-list-link" href="/categories/C/etc/">etc.</a><span class="category-list-count">1</span></li></ul></li><li class="category-list-item"><a class="category-list-link" href="/categories/Math/">Math</a><span class="category-list-count">2</span><ul class="category-list-child"><li class="category-list-item"><a class="category-list-link" href="/categories/Math/Combinatorics/">Combinatorics</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/Math/Geometry/">Geometry</a><span class="category-list-count">1</span></li></ul></li><li class="category-list-item"><a class="category-list-link" href="/categories/Talk/">Talk</a><span class="category-list-count">1</span></li></ul>
</div>
</div>
<div class="widget-wrap">
<h3 class="widget-title">Archives</h3>
<div class="widget">
<ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/06/">June 2016</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/07/">July 2015</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/05/">May 2015</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/03/">March 2015</a><span class="archive-list-count">1</span></li></ul>
</div>
</div>
<div class="widget-wrap">
<h3 class="widget-title">Recent Posts</h3>
<div class="widget">
<ul>
<li>
<a href="/2016/06/29/开新坑/">开新坑</a>
</li>
<li>
<a href="/2015/07/01/求最长等差数列/">求最长等差数列</a>
</li>
<li>
<a href="/2015/05/19/n个球放到m个盒子里/">n个球放到m个盒子里</a>
</li>
<li>
<a href="/2015/05/14/Minkouski距离/">Minkouski距离</a>
</li>
<li>
<a href="/2015/05/08/homebrew滚动更新的问题/">Homebrew滚动更新的问题</a>
</li>
</ul>
</div>
</div>
</aside>
</div>
<footer id="footer">
<div class="outer">
<div id="footer-info" class="inner">
<!-- © -->
2016 pakchoi<br>
Published under <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/" target="_blank">(CC) BY-NC-SA</a>
</div>
</div>
</footer>
</div>
<nav id="mobile-nav">
<a href="/" class="mobile-nav-link">Home</a>
<a href="/archives" class="mobile-nav-link">Archives</a>
<a href="//github.com/pakchoi" class="mobile-nav-link">Github</a>
</nav>
<!-- totop start -->
<div id="totop">
<a title="totop"><img src="/img/scrollup.png"/></a>
</div>
<!-- totop end -->
<!-- 多说公共js代码 start -->
<script type="text/javascript">
var duoshuoQuery = {short_name:"pakchoi"};
(function() {
var ds = document.createElement('script');
ds.type = 'text/javascript';ds.async = true;
ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
ds.charset = 'UTF-8';
(document.getElementsByTagName('head')[0]
|| document.getElementsByTagName('body')[0]).appendChild(ds);
})();
</script>
<!-- 多说公共js代码 end -->
<!-- 百度分享 start -->
<!-- 百度分享 end -->
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link rel="stylesheet" href="/fancybox/jquery.fancybox.css" type="text/css">
<script src="/fancybox/jquery.fancybox.pack.js" type="text/javascript"></script>
<! -- mathjax config similar to math.stackexchange -->
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
displayMath: [ ["$$","$$"], ["\\[","\\]"] ],
processEscapes: true
}
});
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
}
});
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Queue(function() {
var all = MathJax.Hub.getAllJax(), i;
for(i=0; i < all.length; i += 1) {
all[i].SourceElement().parentNode.className += ' has-jax';
}
});
</script>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<script src="/js/script.js" type="text/javascript"></script>
</div>
</body>
</html>