Content #
- as soon as As soon as I sat down, the turned on the TV.
- while She washed the dished while he dried them. 男人女人同时在做不同的事。
- until She was my boss until she quit last month. 女人在辞职之前都是他的老板。
用when时要用时态来表示清楚事件发生的先后顺序 while通常指一段时间 两个一般过去时句子之间添加连词来表示事件发生的顺序 过去进行时的被动语态(was/were being)
forget to do & forget doing remember to do & remember doing try to do & try doing stop to do & stop doing would & used to wind down be about to & be due to & be to
表达恼怒的句型 讽刺地表达烦燥 表达主观推断 依我看 表达精确信息(very, right) 持保留意见&表达反驳 柔和地表达不同意 表达模棱两可的意味 坚定的决心 描述某人的特质 辞职的原因 应对惨淡的就业市场 重述对方观点
For each vertex v, the single-source shortest paths algorithms maintain an attribute v.d, which is an upper bound on the weight of a shortest path from source s to v.
The process of relaxing an edge (u,v) consists of testing whether going through vertex u improves the shortest path to vertex v found so far and, if so, updating v.d and v.π.
RELAX(u, v, w)
if v.d > u.d + w(u, v)
v.d = u.d + w(u, v)
v.π = u
Shortest path cannot contain a negative-weight cycle, nor cat it contain a positive-weight cycle, since removing the cycle from the path produces a path with the same source and destination vertices and a lower path weight.
Shortest path have no cycles, that is, they are simple paths. Since any acyclic path in a graph G=(V,E) contains at most |V| distinct vertices, it also contains at most |V|-1 edges. Therefore, any shortest path contains at most |V|-1 edges;
...If the graph contains a negative-weight cycle reahable from s, however, shortest-path weights are not well defined.
There are infinitely many paths from s to c:
<s,c>, <s,c,d,c>, <s,c,d,c,d,c>, ...
The shortest path from s to c is <s,c>.
There are infinitely many paths from s to e:
<s,e>, <s,e,f,e>, <s,e,f,e,f,e>, ...
Because the cycle <e,f,e> has weight -3, however, there is no shortest path from s to e.
...人类语言的另一独特之处是元音的发音。没有元音便不可能有语言,元音将一串声音切分为易于分辨的小节(音节)从而形成词语。长期以来人们认为猴类和猿类无法发出元音,因其口腔和喉腔构造欠佳。然而,几项最新研究发声方式的结果表明,狮尾狒和猕猴等能够发出类似的元音。这意味着在进化的过程中,远在人类出现之前,人类话语的发声机制便已存在。
问题不在于发声机制,而在于协调发声和赋予声音意义的认知机制(但长尾黑颚猴的研究表明,最后这点存在疑问)。换言之,我们已能在旧世界猴身上看到许多人类话语的雏形。长尾黑颚猴的呼叫声是一种原始语原型,随意发声来指代具体物体,传达谁在做什么的信息(或将要做什么)。此外,呼叫声背后隐含着不同程度的情感含义,一如我们的语言表达。
可见,语言的产生无须经过手势阶段演变而来,声音表达足以。由此进化形成固定声音模式仅需一小步,便可传达更多信息,然后再向前一小步,便可产生语言。
《梳毛、八卦及语言的进化》 [英]罗宾·邓巴
需要读入的数据如下:
4
1 2 3 4
2 1 3
3 1 2 4
4 1 3
0
0
最开始的数字N,表示图的节点的个数,接下来若干行。每行的第1个数字表示起点u,后续的数字v表示从u开始到v有一条边。如果第1个数字为0,表示图的输入结束。
读取的代码如下:
int N;
while (cin >> N && N > 0) {
string s;
while (getline(cin, s)) {
istringstream iss(s);
int u;
iss >> u;
if (u == 0) break;
int v;
while (iss >> v) {
//...
}
}
}
上面的代码存在换行符陷阱。读取N后,第1行的换行符还在,接下来调用 getline时,会得到空行,第1轮循环会马上结束,进入第2轮循环后会将第2行的第1个数字当作N读进来,导致数据读取错误。
解决方法是在读取N后,调用cin.ignore()来丢弃换行符:
int N;
while (cin >> N && N > 0) {
cin.ignore(); //忽略当前的换行符,没有这一句,第一次调用getline会得到空行。
//...
}
getline官方文档说明: When consuming whitespace-delimited input (e.g. int n; std::cin >> n;) any whitespace that follows, including a newline character, will be left on the input stream. Then when switching to line-oriented input, the first line retrieved with getline will be just that whitespace. In the likely case that this is unwanted behaviour, possible solutions include:
...