由买买提看人间百态

topics

全部话题 - 话题: dist
1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
w****x
发帖数: 2483
1
1 function Dijkstra(Graph, source):
2 for each vertex v in Graph:
3 dist[v] := infinity ;
4
5 previous[v] := undefined ;
6
7
8 dist[source] := 0 ;
9 Q := the set of all nodes in Graph ; ... 阅读全帖
w********u
发帖数: 328
2
I want to calculate the POWER.
SAS code:
proc power;
onesamplemeans
mean = 8
ntotal = 150
stddev = 40
power = .;
run;
This method makes sense when it follows normal dist., but my case is that
the sample size is extremely small but the population is very large, i can't
say that it follows normal dist., i assume it doesn't follow any particular
dist. but i haven't got the data yet, i wonder which method could be used
in this case and what's the sample size needed to conduct any analysis. for
examp
w********u
发帖数: 328
3
the sample size is extremely small but the population is very large, for
example, the frequency of some cancer is extremely low.so it doesn't make
sense to say that the sample follows normal dist.
my question is
1 at least how many sample roughly i need to conduct a power analysis or
what's the lowest frequency to conduct a power analysis
2 the proc power in SAS is for normal dist.power analysis, so which method
could be used in this case, SAS preferred.
Thank you!
C***i
发帖数: 486
4
来自主题: DataSciences版 - 如何用不同来源的Obs来fit 一个 Dist.
一个project 中的一个小环节,有个问题向各位高人请教下。问题抽象出来是,客户找
到一些历史数据 (数据源=20)。因为是历史数据,而且报告地点比较离散,数据质量
很差。具体来讲,数据的样本不同,观测条件也不一致。。。 大概看起来如下:
Study 1: # of obs 100, [1,2,3,...., 100], location A, sample condition I,
etc...
Study 2: # of obs 10, [5, 7, 9,....], location B, sample condition I, etc...
Study 3: # of obs 50, [20, 25, 30, 35, ...], , location C, sample condition
II, etc...
客户想把这些数据都pool 在一起 fit 一个distribution. 我认为因为不同study, 样
本数量不同,不能简单的混在一起。因为一定要给出一个dist., 我的想法是:
1. 根据现有的conditions, merge 类似的数据,比如合并 在同一个... 阅读全帖
j********u
发帖数: 182
5
马上要去Amazon位于SLU的办公楼上班,请求板上各位朋友提供下租房建议。我搜了位
于Belltown, Capitol Hill, Queen Ann和University District的一些apartments,也
实地考察了几个,发现SLU那一大片加上Belltown和 Capitol Hill的北边,基本上是人
不算多,够安静,离公司很近...步行距离,没发现有适合中国人吃饭的餐馆,也没什
么中国人,生活貌似很单调的样子。后来又去了University District,挺热闹的,吃
喝一条街还是很给力的,日常生活也应该方便许多,但就是离公司比较远,google map
上显示需要30分钟bus,是完全可以接受的,但不知早晚车上会不会很挤,挤到车都上
不去的那种,也不清楚西雅图的公交系统到底如何?
以上是我在西雅图找了一个星期房子的一点点看法,请大家批评然后给些租房地点的建
议。我单身,没买车,可能一时半会也买不了,所以交通方便暂排第一位吧。住house
还是apartment无所谓,合租或自己单租都可以, Univ Dist再往北我就没去过了。先谢
谢啦
F*******i
发帖数: 190
6
今天,
apt-get dist-upgrade,
login xfce 后, 整个 mouse/keyboard 就没有响应了。
linux-kernel 2.6.29
nvidia gt-8600
note: 看到 有好一些 xorg 相关的包 被升级了。
是不是只能干等 debian fix 这些 xorg 相关的升级?
高手请点解。
m*********g
发帖数: 273
7
yes.
Because it is not complete. You downgrade though. Be careful when run the
dist-upgrade for debian/sid.
c*****z
发帖数: 182
8
【 以下文字转载自 Linux 讨论区 】
发信人: cmsdkfz (heibao), 信区: Linux
标 题: make dist 是什么命令阿,能否举个例子
发信站: BBS 未名空间站 (Mon Feb 12 00:26:30 2007), 站内
谢谢先
n******7
发帖数: 12463
9
在cluster上用,系统自带的是python2.6 和 python3
我local install了python2.7,然后用easy_install 装了numpy,scipy
现在我想重点使用python的这一些列tools,包括pandas matlibplot
感觉Anaconda dist应该不错
但是担心会不会造成混乱,连现在的numpy scipy都不能用了?
有经验的麻烦说说看
谢谢
C***i
发帖数: 486
10
来自主题: DataSciences版 - 如何用不同来源的Obs来fit 一个 Dist.

谢谢回复。看了一下数据的分布,跨度比较大,但基本上算是normal dist., 不过这
个数据采集来源于多个国家,实在太分散 (见下图)。最后决定从几个 datasets 里
bootstrap
出一个算了,当然是假设每个数据源都给予同样比重。 请问这个方法可行么?
m*****g
发帖数: 71
11
只用constant内存的DP解法,自测能过所有test case
public boolean isDistanceZeroOrOne(IntFileIterator a, IntFileIterator b)
{
int up = 1;
int left = 1;
int diagnal = 0;
int dist = 0;
int currA = 0;
int currB = 0;
int prevA = 0;
int prevB = 0;

if (a.hasNext() && b.hasNext()) {
prevA = a.next();
prevB = b.next();
if (prevA == prevB) {
dist = 0;
} else {
... 阅读全帖
g****e
发帖数: 172
12
那些suspicious files安全吗?
多谢!!
sudo chkrootkit
ROOTDIR is `/'
Checking `amd'... not found
Checking `basename'... not infected
Checking `biff'... not found
Checking `chfn'... not infected
Checking `chsh'... not infected
Checking `cron'... not infected
Checking ... 阅读全帖
g****e
发帖数: 172
13
【 以下文字转载自 Linux 讨论区 】
发信人: gangle (nothing), 信区: Linux
标 题: 请高手帮忙看看这个chkrootkit安全否?
发信站: BBS 未名空间站 (Mon Aug 13 18:29:14 2012, 美东)
那些suspicious files安全吗?
多谢!!
sudo chkrootkit
ROOTDIR is `/'
Checking `amd'... not found
Checking `basename'... not infected
Checking `biff'... not found
Checking `chfn'... not infected
Checking `chsh'... ... 阅读全帖
f*******a
发帖数: 663
14
来自主题: DataSciences版 - Science上新clustering算法的分析测试
开始忘贴代码了,有朋友要求,就把修改后的代码贴在这里。改动不多,可以部分提升
效率。原来的也没删,注释掉了。供参考。
=========================================================================
clear;
close all
disp('The only input needed is a distance matrix file')
disp('The format of this file should be: ')
disp('Column 1: id of element i')
disp('Column 2: id of element j')
disp('Column 3: dist(i,j)')
if(0)
% mdist=input('name of the distance matrix file (with single quotes)?\n'
);
mdist = 'example_distances.dat';

disp('Reading input dis... 阅读全帖
b**********r
发帖数: 91
15
来自主题: JobHunting版 - 问道amazon的面试题
Run the ultimate example around 400 ms
here is my code
4, 13, 5, 4, 13, 6, 8, 12, 16, 9, 13, 13, 13, 16, 9, 2, 6, 5,
0, 4, 17, 22, 26, 39, 45, 53, 65, 81, 90, 103, 116, 129, 145, 154, 156,
162, 167,
4, 17, 22, 26, 39, 45, 53, 65, 81, 90, 103, 116, 129, 145, 154, 156,
162, 167, 13, 18, 22, 35, 41, 49, 61, 77, 86, 99, 112, 125, 141, 150,
152, 158, 163, 5, 9, 22, 28, 36, 48, 64, 73, 86, 99, 112, 128, 137, 139,
145, 150, 4, 17, 23, 31, 43, 59, 68, 81, 94, 107, 123, 132, 134, 140,
145, 13, 19, 27, 39... 阅读全帖
b**********r
发帖数: 91
16
来自主题: JobHunting版 - 问道amazon的面试题
Run the ultimate example around 400 ms
here is my code
4, 13, 5, 4, 13, 6, 8, 12, 16, 9, 13, 13, 13, 16, 9, 2, 6, 5,
0, 4, 17, 22, 26, 39, 45, 53, 65, 81, 90, 103, 116, 129, 145, 154, 156,
162, 167,
4, 17, 22, 26, 39, 45, 53, 65, 81, 90, 103, 116, 129, 145, 154, 156,
162, 167, 13, 18, 22, 35, 41, 49, 61, 77, 86, 99, 112, 125, 141, 150,
152, 158, 163, 5, 9, 22, 28, 36, 48, 64, 73, 86, 99, 112, 128, 137, 139,
145, 150, 4, 17, 23, 31, 43, 59, 68, 81, 94, 107, 123, 132, 134, 140,
145, 13, 19, 27, 39... 阅读全帖
j*p
发帖数: 411
17
来自主题: Biology版 - 贡献一个SNP/Indel calling pipeline
攒人品,顺便回答一下 iiiir 的问题。
我们尝试过好几种不同的SNP calling的方法,包括GATK, Samtools, Varscan,
SeqGenes, 等,并且做了SNP array 作为gold standard比较各种方法的prediction
power。
从我们的经验,BWA + GATK 最好,sensitivity 和 specificity 都在95%以上。
以下是GATK 的pipeline
假设你有一个control 样品C 和一个样本样品A的pair-end sequencing,共4个文件,C
_R1.fastq, C_R2.fastq, A_R1.fastq and A_R2.fastq如何通过BWA/GATK去找样品A中
的SNPs (相对于C)
假设assembly 用的是hg19,你的BWA index 在这里:/bwa/indexes/hg19
Check this website if you have any questions:
http://seqanswers.com/wiki/How-to/exome_analysis
#s... 阅读全帖
j*p
发帖数: 411
18
来自主题: Biology版 - 贡献一个SNP/Indel calling pipeline
攒人品,顺便回答一下 iiiir 的问题。
我们尝试过好几种不同的SNP calling的方法,包括GATK, Samtools, Varscan,
SeqGenes, 等,并且做了SNP array 作为gold standard比较各种方法的prediction
power。
从我们的经验,BWA + GATK 最好,sensitivity 和 specificity 都在95%以上。
以下是GATK 的pipeline
假设你有一个control 样品C 和一个样本样品A的pair-end sequencing,共4个文件,C
_R1.fastq, C_R2.fastq, A_R1.fastq and A_R2.fastq如何通过BWA/GATK去找样品A中
的SNPs (相对于C)
假设assembly 用的是hg19,你的BWA index 在这里:/bwa/indexes/hg19
Check this website if you have any questions:
http://seqanswers.com/wiki/How-to/exome_analysis
#s... 阅读全帖
g**********y
发帖数: 14569
19
来自主题: JobHunting版 - 问道amazon的面试题
主要是Bravethinker的code, 改动很小:
1. 试candidate时,对相同值,用index最小的那个,这样往下滑得更快。
2. founded不用ArrayList, 改成数组,速度更快。
3. 测试candidate时,直接改map; 测试不通过时revert修改。不过这个改动好象无关
紧要,不怎么影响速度。
public class BraveThinker implements IMilestone {
private int dfsCount = 0;
public int[] findMilestones(int[] dists) {
long t0 = System.currentTimeMillis();

dfsCount = 0;

int L = dists.length;
int N = (int) ((Math.sqrt(1 + 8 * L) - 1) / 2);
int[] founded = new int[N+1];... 阅读全帖
g**********y
发帖数: 14569
20
来自主题: JobHunting版 - 问道amazon的面试题
主要是Bravethinker的code, 改动很小:
1. 试candidate时,对相同值,用index最小的那个,这样往下滑得更快。
2. founded不用ArrayList, 改成数组,速度更快。
3. 测试candidate时,直接改map; 测试不通过时revert修改。不过这个改动好象无关
紧要,不怎么影响速度。
public class BraveThinker implements IMilestone {
private int dfsCount = 0;
public int[] findMilestones(int[] dists) {
long t0 = System.currentTimeMillis();

dfsCount = 0;

int L = dists.length;
int N = (int) ((Math.sqrt(1 + 8 * L) - 1) / 2);
int[] founded = new int[N+1];... 阅读全帖
a***e
发帖数: 2427
21
来自主题: SanFrancisco版 - 6/3加州初选,aside个人负责任推荐
首先,本人立场是不管三七二十一投共和党。
即使是在共和党无望胜利的位置,我还是希望华人能够团结一心去投共和党,而不是去
投一个“不太坏”的民主党。说实话,华人的人口很少,其实很难靠选票来一下子改变
选举结果。但是选举后的分析如果显示华人把票都投给了共和党,这会是一个明显的信
号。而如果华人的票还是给了民主党,不管是哪个人,民主党都会认为华人还是那个任
他们宰割的乌合之众。
有些民主党员同时也得到了共和党的推荐,应该算是比较中间派的。
以下位置,没有提到党派的都是共和党。没有推荐的职位请尽量选共和党。
Governor(州长)
# Tim Donnelly ; 本人大力推荐。现任众议员,经济保守派的茶党 我一直想为茶党
正名。茶党的宗旨是小政府,不加税,平衡预算,而且尽量不碰社会议题。 http://en.wikipedia.org/wiki/Tea_Party_movement 。 Tim本人拥有家里传下来的small business. 坚定反非法移民,曾经参加过边境巡逻。他在领导推翻Dream Act (让非法移民在加州公立大学享受州内学费)。
# Neel Kashkari... 阅读全帖
d*k
发帖数: 207
22
来自主题: JobHunting版 - Gas station II
題目的意思應該是從原點(0)到最後一點(n-1),而不是像gas station要從任意點走
一圈。抛砖引玉说一个复杂度较高的DP。
f(i, p)表示位於i點,油量為p時候的解。令m = P + B(0) + B(1) + ... + B(n-1) 。
dist(i, j)表示i, j兩點間的距離。
顯然對於0 <= p <= m,有f(n-1, p) = 0
對於f(i, j), 0 <= i <= n -2, 0 <= j <= m,
若j >= dist(i, n - 1)則f(i, j) = 0
否則f(i, j) = 1 + min(f(k+1, j - dist(i, k+1) + B(k)), k需要滿足條件
(1) i <= k <= n - 2。
(2) j >= dist(i, k)
(3) j - dist(i, k) + B(k) >= dist(k, k+1)
(4) f(k + 1, j - dist(i, k+1 ) + B(k)) >= 0
若無滿足條件的k,則f(i,j) = -1
最後返回f(0, P)。时间复杂度n * n * m。
我想如果... 阅读全帖
d*k
发帖数: 207
23
来自主题: JobHunting版 - Gas station II
題目的意思應該是從原點(0)到最後一點(n-1),而不是像gas station要從任意點走
一圈。抛砖引玉说一个复杂度较高的DP。
f(i, p)表示位於i點,油量為p時候的解。令m = P + B(0) + B(1) + ... + B(n-1) 。
dist(i, j)表示i, j兩點間的距離。
顯然對於0 <= p <= m,有f(n-1, p) = 0
對於f(i, j), 0 <= i <= n -2, 0 <= j <= m,
若j >= dist(i, n - 1)則f(i, j) = 0
否則f(i, j) = -1, 若dist(i, i+1) > B(i) + j
= 1 + f(i+1, j + B(i) - dist(i, i + 1), 若 j < dist(i, i + 1)
<= j + B(i)
= min(1 + f(i+1, j + B(i) - dist(i, i + 1), f(i+1, j)), 若
dist(i, i+1) <= j
最後返回f(0, P)。时间复杂度n * m。
我想... 阅读全帖
f**********t
发帖数: 1001
24
来自主题: JobHunting版 - Linkedin 电面 面经x2
void shuffle(vector &vi) {
for (size_t i = 0; i < vi.size(); ++i) {
size_t k = rand() % (vi.size() - i);
swap(vi[i], vi[i + k]);
}
for_each(vi.begin(), vi.end(), [](int x) {
cout << x << ' ';
});
cout << endl;
}
/*
* Example:
* WordDistanceFinder finder = new WordDistanceFinder(Arrays.asList("the",
"quick", "brown", "fox", "quick"));
* assert(finder.distance("fox","the") == 3);
* assert(finder.distance("quick", "fox") == 1);
*/
class WordDistanceFinder {
vector... 阅读全帖
S*******s
发帖数: 13043
25
来自主题: Chicago版 - Is Chicago the Next Detroit?
here is break down:
Taxing Body Rate
COUNTY OF LAKE 0.491
COUNTY OF LAKE PENSION 0.117
ROAD AND BRIDGE-LIBERTYVILLE 0.057
COUNTRYSIDE FIRE PROT DIST 0.481
COUNTRYSIDE FIRE PROT DIST PENSION 0.071
COOK MEMORIAL PUBLIC LIBRARY DIST 0.257
COOK MEMORIAL PUBLIC LIBRARY DIST PENSION 0.025
VERNON HILLS PARK DIST 0.496
HAWTHORNE COMM CONS SCHOOL DISTRICT #73 3.557
HAWTHORNE COMM CONS SCHOOL DISTRICT #73 PENSION 0.121
COLLEGE OF LAKE COUNTY #532 0.272
LIBERTYVILLE COMM HIGH SCHOOL DIST #128 2.508
LIBERTY... 阅读全帖
h****g
发帖数: 772
26
http://www.tutorialspoint.com/python/python_cgi_programming.htm 'filename'
系统是debian squeeze, python 2.6.6, apache2
错误信息如下
Phase: 'PythonHandler'
Handler: 'mod_python.publisher'
Traceback (most recent call last):
File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 1537,
in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)
File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 1229,
in _process_target
result = _execut... 阅读全帖
g**********y
发帖数: 423
27
来自主题: Biology版 - NGS_Illumina类
欢迎讨论,特别是各种程序的调用参数 。。。
http://dl.dropbox.com/u/62547840/NGS_Illumina.pm
http://dl.dropbox.com/u/62547840/NGS_Illumina.pl
screen output:
Illumina 1.3+ fastq format: ASCII(min, max) = (66, 102)
2012/08/25 11:41:15 START maq ill2sanger Run1_testicular-28T_lane2_read1_
sequence.txt Testis_T28_read1_sanger.fq
2012/08/25 11:42:57 SUCCESS after running 0 hours 1 minutes 42 seconds
2012/08/25 11:42:57 START maq ill2sanger Run1_testicular-28T_lane2_read2_
sequence.txt Testis_T28_read2_sanger.fq
2012/08/25... 阅读全帖
a********a
发帖数: 346
28
来自主题: Statistics版 - proc lifereg,distribution selection
%macro surv(dist=);
proc lifereg data=surv_w2;
class PERFSTAT;
model log_day*censor(1)=PERFSTAT base_ts_center PTRWK8 /dist=&dist;
run;
%mend;
%surv(dist=lnormal);
%surv(dist=exponential);
%surv(dist=weibull);
%surv(dist=gamma);
I am running proc lifereg with different distribution for the model. I got
Log likelihood for different distributions as following. Which distribution
I should use? How exponential distribution can be this worse with only 1
degree of freedom difference with weibu
k*****y
发帖数: 744
29
来自主题: JobHunting版 - 一道google 经典题
考虑六种从小到大排列的可能情况,每种找出最小的distance,再一起比较。
import random
# generate random data
data = [[],[],[]]
for i in range(0,3):
N = random.randint(5, 10)
for j in range(0, N):
data[i].append(random.randrange(0, 1000))
data[i].sort()
test_cases = [(0,1,2), (0,2,1),
(1,0,2), (1,2,0),
(2,0,1), (2,1,0)]
pos = [[]]*len(test_cases)
dist = [1000000]*len(test_cases)
def LowerBound(x, queueID, start):
for i in range( start, len(data[queueID]) ):
if data[queu... 阅读全帖
k*****y
发帖数: 744
30
来自主题: JobHunting版 - 一道google 经典题
考虑六种从小到大排列的可能情况,每种找出最小的distance,再一起比较。
import random
# generate random data
data = [[],[],[]]
for i in range(0,3):
N = random.randint(5, 10)
for j in range(0, N):
data[i].append(random.randrange(0, 1000))
data[i].sort()
#=============================
test_cases = [(0,1,2), (0,2,1),
(1,0,2), (1,2,0),
(2,0,1), (2,1,0)]
pos = [[] for i in range(len(test_cases))]
dist = [1000000]*len(test_cases)
def LowerBound(x, queueID, start):
for i in range( st... 阅读全帖
j*****s
发帖数: 189
31
来自主题: JobHunting版 - 一道题
用DP好一些
for(int i = 1 ; i< n1 + 1; ++i){
for (int j = 1; j < n2 + 1; ++j){
if (word1[i - 1] == word2[j - 1])
{
dist[i][j] = dist[i - 1][j - 1];
}
else{
dist[i][j] = min(dist[i - 1][j - 1], dist[i - 1][j],
dist[i][j - 1]) + 1;
}
}
}
T*****u
发帖数: 7103
32
来自主题: JobHunting版 - linkedin电面题
python初学者贴个python的
def dist(word1, word2):
wordlist = ['this','this','is']
l1,l2 = -1,-1
dist = len(wordlist)
for p in range(len(wordlist)):
if word1==wordlist[p]:
l1 = p
if word1==word2:
l1,l2 = l2,l1
elif word2 == wordlist[p]:
l2 = p
if l1*l2>-1:
if dist>abs(l2-l1):
dist = abs(l2-l1)
if dist==len(wordlist): return None
else: return dist
T*****u
发帖数: 7103
33
来自主题: JobHunting版 - linkedin电面题
python初学者贴个python的
def dist(word1, word2):
wordlist = ['this','this','is']
l1,l2 = -1,-1
dist = len(wordlist)
for p in range(len(wordlist)):
if word1==wordlist[p]:
l1 = p
if word1==word2:
l1,l2 = l2,l1
elif word2 == wordlist[p]:
l2 = p
if l1*l2>-1:
if dist>abs(l2-l1):
dist = abs(l2-l1)
if dist==len(wordlist): return None
else: return dist
s****i
发帖数: 152
34
平权会有研究结论啊!我邮箱收到了,要不给你贴在这?
2016大选投票指南
本投票指南经过圣地亚哥亚裔平权会理事会讨论,12位现任理事中8位理事出席会议,
另有2名投票会员出席,所有有建议的均是至少7人(参加会议的10人中绝对多数2/3)
持相同观点才有建议,如果未达到绝对多数则没有建议。每个提案及候选人后的数字,
按照顺序分别为赞成、弃权和反对最终选择的与会人员数量。
对于平权会没有建议的投票项目,您可以自己做研究选择符合自己心意的候选人或提案
,也可以不做任何选择,只选你确定的选项,您的选票仍然是有效的。
州级提案指南:
Prop 51: 州政府发行90亿美元债券用于校舍修缮。
建议:No。
理由:全州90亿美元杯水车薪,无法有效分配,应该由各个学区自行发行债券解决校舍
修缮问题。(9/1/0)
Prop 52: 目前加州已经把一些医疗费用转移到general fund里面去挪用。本提案要求
,医院的funds改变使用用途需要选民投票通过。
建议:Yes。医疗费用既然是专项费用,就应该专款专用。要提高政府随意支配资金的
门槛。(10/0/0)
Prop 53:超过20亿美元的reve... 阅读全帖
t****a
发帖数: 1212
35
来自主题: JobHunting版 - Google onsite 5天后被拒了
classic DP problem.
dist(A[1:n], B[1:m]) = minimal (
dist(A[1:n-1], B[1:m]) + 1,
dist(A[1:n], B[1:m-1] + 1,
dist(A[1:n-1], B[1:m-1]) if A[n]==B[m],
dist(A[1:n-1], B[1:m-1]) + 1 if A[n]!=B[m]
)
the complexity is O(n*m)
l*****y
发帖数: 56
36
来自主题: JobHunting版 - 一道google 经典题
像楼主说的,每次把最小的往上移。
用了三个指针,分别指向三个数组,中间会交换指针,min, mid, max,他们分别指向
三个从小到到大排列的数, 距离就是 *max -*min.
最后return the minimal distance, the vector d records the three elements
with minimal distance.
请指正, 谢谢了!
void swap(vector::iterator &a, vector::iterator &b){
vector::iterator temp;
temp=a;

a=b;
b=temp;
}
int min_dist(vector &a, vector &b, vector &c, vector &d){
vector::iterator min=a.begin(), mid=b.begin(), max=c.begin();
int dist=100... 阅读全帖
l*****y
发帖数: 56
37
来自主题: JobHunting版 - 一道google 经典题
像楼主说的,每次把最小的往上移。
用了三个指针,分别指向三个数组,中间会交换指针,min, mid, max,他们分别指向
三个从小到到大排列的数, 距离就是 *max -*min.
最后return the minimal distance, the vector d records the three elements
with minimal distance.
请指正, 谢谢了!
void swap(vector::iterator &a, vector::iterator &b){
vector::iterator temp;
temp=a;

a=b;
b=temp;
}
int min_dist(vector &a, vector &b, vector &c, vector &d){
vector::iterator min=a.begin(), mid=b.begin(), max=c.begin();
int dist=100... 阅读全帖
y**********a
发帖数: 824
38
来自主题: JobHunting版 - 最新L家面经
class MinDist{
Map dist;
String separator;
int minDist(String s1, String s2, Map>map) {
dist=new HashMap<>();
Listl1,l2;
if ((l1=map.get(s1))==null||(l2=map.get(s2))==null) return -1;
int rel=Integer.MAX_VALUE;
for(int i1=0,i2=0;i1 int v1=l1.get(i1),v2=l2.get(i2),dif=v1-v2;
rel=Math.min(rel,Math.abs(dif));
if (rel==1) return 0;
el... 阅读全帖
m*********g
发帖数: 10735
39
LZ做的事情不是AGENT啊
美国很多厂家就是只负责设计和生产,可能有一个独立的子公司专门负责销售,子公司
直接卖给END USER,或者更普遍的,卖给各个DISTRIBUTOR。分销商存在的意义就是帮
助厂家推销出去更多的产品,LZ做的事情就是类似分销商的性质
首先一个很现实的情况,就是很多厂家就是不直接卖给END USER,因为厂家就是不喜欢
跟END USER打交道,觉得麻烦,你联系厂家,厂家就会把你FORWARD给某个DIST/SALES
BRANCH;其次,你直接买不见得更划算,DIST可能因为每年订货量巨大,可以从厂家拿
到很好的DISCOUNTED PRICE,可能是50% OFF LIST PRICE,至于DIST想以什么样的价格
卖给自己的客户,那就完全取决于DIST自己了,想拉住某个客户的话,可以适当牺牲自
己的利润,也许只在自己成本的基础上MARK UP BY 10%,最终客户到手的价格就很便宜
,但如果直接跟厂家买,厂家可能觉得你这个就是一个ONE TIME ORDER,不可能上量,
也许就给你一个20% OFF LIST之类的,这样最终搞下来,还不如跟DIST... 阅读全帖
U***J
发帖数: 5998
40
来自主题: WashingtonDC版 - MC的Property Tax 又要涨了
In separate decisions Wednesday, the Montgomery County Council indicated its
intention to approve an increase in the county's property tax rate this
year and cutbacks in government employee benefits.
The tax hike the council appears to favor is a 4.2 cent increase per $100 of
assessed property value — raising the rate from 90.4 cents to 94.6 cents.
Most property tax bills in the county will go up less than 1 percent.
The tax increase was first proposed by County Executive Isiah Leggett (D) in
Ma... 阅读全帖
I**********O
发帖数: 493
41
来自主题: loseweight版 - [参加活动]健康生活
09/28/2012
-outdoor running:
Time: 25 mins
Dist: 1.83 miles
-Breaststroke
Time: 40 mins
Dist: 1500 yards
09/29/2012
-kick boxing
Time: 60 mins
-outdoor running
Time: 62mins
Dist; 4.35 miles
09/30/2012
-indoor running
Time: 40 mins
Dist: 3.68 miles
10/01/2012
-outdoor running
Time: 24 mins
Dist; 1.67 miles
m******s
发帖数: 204
42
来自主题: Programming版 - 请教关于link error (C++)的基本问题
用的是VS 2008。我想将代码分成几个文件:
1。vec.h
#ifndef _VEC_H_
#define _VEC_H_
class vec3{
float dist(vec3 &v)
};
2. vec.pp
#include "vec.h"
// Implement dist function
float vec3::dist(vec3 &v)
3. main.cpp
#include "vec.h"
void f()
{
vec3 v1(1,1,1);
vec3 v2(1,1,1);
float len = v1.dist(v2);
}
这三个文件在同一个project里面,但仍然得到linkerror 2019,dist unresolved...
没google到有用的解释,请大家旁忙看看,多谢!
f*******l
发帖数: 828
43
我用 genmod fit一个数据,看起来response variable的分布可以是lognormal也可能
是gamma... 然后我用link=log dist=normal算出来的结果比link=log, dist=gamma的
AIC/BIC大,这样是不是一定就要用link=log dist=gamma了.
可是我觉得link=log dist=normal不是更能说明lognormal么(或者我理解错了?),
然后gamma的canonical link不是应该是 1/ ?
我特别希望能用link=log dist=normal算出来的结果,但是因为BIC大一些,所以不知
道怎么写report... 是不是有别的方法来看genmod下那种方法更好呢?
s**********r
发帖数: 141
44
来自主题: JobHunting版 - Discuss: A google binary search problem
Key observation:
if there's a sequence S (S[0] < S[1] < ... < S[k-1]) which has size k and
it's min-dist is w in sorted array A, then we can derive another sequence
Z (Z[0] < Z[1] < ... < Z[k-1]) with size k, and Z has min-dist w1 >= w.
Hint: Since S[0] >= A[0], if you substitute S[0] with A[0], and the
sequence S now has min-dist >= w; you can move one more step to
substitutes S[1] with A[j] s.t. A[j] >= A[0]+w and A[j-1] < A[0]+w, and
the sequence now still has min-dist >=w. Pushing this idea
m**q
发帖数: 189
45
来自主题: JobHunting版 - 几道老题 的解答
同样,当检查一个新的点时,需要把x-h之前的点从map中去掉,
其实可以用一个map存[x-h,x]中的点,key是y坐标。在向map中
添加一个新的点时,先检查map里是否有y坐标相同的点,有则删除;
同时把x-h之前的点依据它们的y坐标,把它们从map中删除。
总复杂度不超过O(nlgn)。
#include
#include
#include
#include
#include
using namespace std;
#define REVESE_PAIR(x) (make_pair(x.second, x.first))
#define PAIR(x) (make_pair(x.first, x.second))
double dist(pair a, pair b)
{
int x = abs(b.first - a.first);
int y = abs(b.second - a.second);
doubl... 阅读全帖
g***x
发帖数: 494
46
不是有个典型的解法吗?
int maxdist(int *a, int num)
{
int *min=new int[num];
int *max=new int[num];
int i,j,k;
int t=INT_MAX;
for(i=0;i {
if(a[i] min[i]=a[i];
t=a[i];
}
else
min[i]=t;
}
t=INT_MIN;
for(i=num-1,i>=0;i--){
if(a[i]>t){
max[i]=a[i];
t=a[i];
}
else
max[i]=t;
}
i=0;j=0;
dist=-1;
while(i if(min[i] dist=max(dist, j-1);
j++;}
else
i++;
}
return dist;
}
空间复杂度n,min可以用一个变量代替,max不知道可不可以用什么方法去掉?
}
}
d******e
发帖数: 164
47
来自主题: JobHunting版 - leetcode出了新题word ladder
贴个第一题,
class Solution {
public:
int ladderLength(string start, string end, unordered_set &dict) {
queue q;
queue cnt;
unordered_set visited;
q.push(start);
cnt.push(1);
if (start != end) visited.insert(start);
while (!q.empty()) {
string word = q.front(); q.pop();
int dist = cnt.front(); cnt.pop();
if (dist > 1 && word == end) return dist;
for (int i = 0; i < w... 阅读全帖
d******e
发帖数: 164
48
来自主题: JobHunting版 - leetcode出了新题word ladder
贴个第一题,
class Solution {
public:
int ladderLength(string start, string end, unordered_set &dict) {
queue q;
queue cnt;
unordered_set visited;
q.push(start);
cnt.push(1);
if (start != end) visited.insert(start);
while (!q.empty()) {
string word = q.front(); q.pop();
int dist = cnt.front(); cnt.pop();
if (dist > 1 && word == end) return dist;
for (int i = 0; i < w... 阅读全帖
b*********k
发帖数: 335
49
http://kathyforstaterep.com/issues/education/
IMPACT OF SB16 TO THE 17TH DISTRICT
Here is how the bill would affect schools in District 17 (numbers from ISBE):
Northbrook / Glenview Dist. 30
FY13 Disbursements = $648,051
Disbursements Under SB 16 = $190,759
Loss = $457,292
- Loses 70% of state funding
Glenview School Dist. 34
FY13 Disbursements = $4,374,854
Disbursements Under SB 16 = $776,666
Loss = $3,598,188
- Loses 82% of state funding
Avoca School Dist. 37
FY 13 Disbursements = $396,564
Dis... 阅读全帖
1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)