由买买提看人间百态

topics

全部话题 - 话题: decrement
首页 上页 1 2 3 下页 末页 (共3页)
z**********g
发帖数: 209
1
来自主题: JobHunting版 - 问一道F家面试题
Given an array A of positive integers. Convert it to a sorted array with
minimum cost. The only valid operation are:
1) Decrement with cost = 1
2) Delete an element completely from the array with cost = value of element
没想清楚。
c********s
发帖数: 817
2
来自主题: JobHunting版 - M onsite面经
如果内存不足,对于每个括号(),{},和 {}, 各用一个counter,而不用stack。
原先的stack push变成counter increment,stack pop 变成counter decrement.
I*******g
发帖数: 7600
3
来自主题: JobHunting版 - 请问一个面试题
Imagine the following compare_and_swap (CAS) primitive function is available
to
you. Using this function, write an integer counter class providing increment,
decrement, set and get APIs in an atomic and thread-safe way in a context
subject to
periodic highly intensive concurrent activity .
/* In a critical section, if (*dest) == old_val, then updates dest to new_
val and returns true otherwise leaves dest unchanged and returns false.
*/
bool compare_and_swap(int* dest, int old_val, int new_val)
y*****e
发帖数: 712
4
来自主题: JobHunting版 - 请教L家新面经题,种花
题目从一亩看来的:
public boolean canPlaceFlowers(List flowerbed, int numberToPlace)
如果flowerbed当中为true,说明已经栽过花了,附近两个不能再栽花。numberToPlace
代表想再栽多少花到flowerbed里。让return是不是还能栽那么多谢花进去。.
这个应该是说如果flowerbed是true false false false false, 那么在Index = 3种一朵
这题是不是用greedy解就行啊?看到一个可以种花的spot就种, 然后decrement
numberToPlace, 如果到最后numberToPlace > 0, 那就不能种。。。
还是需要用DP啊?来一个dp(startPos, flowerLeft), 每一步选择种或者不种?
A*******e
发帖数: 2419
5
来自主题: Money版 - southwest points要过期了
decremented不行?
m**k
发帖数: 18660
6
来自主题: Fitness版 - 锻炼对脂肪氧化能力的影响
http://ajpendo.physiology.org/cgi/content/abstract/00354.2007v1?papetoc
减肥的人。虽然体重降低。但是脂肪酸氧化能力没有提高(还是和胖人一样,同瘦人差
远)
但是运动以后就明显提高.
Obesity is associated with a decrement in the ability of skeletal muscle to
oxidize lipid. The purpose of this investigation was to determine if
clinical interventions (weight loss, exercise training) could reverse the
impairment in fatty acid oxidation (FAO) evident in extremely obese
individuals. FAO was assessed by incubating skeletal muscle homogenates with
1-14C pal
P****D
发帖数: 11146
7
http://www.guokr.com/article/291083/
运动健身,会让你变成肌肉女吗?
绵羊c 2012-07-30 08:48:45
还认为运动会让肌肉变粗?现在要告诉你,肌肉不是那么好练的,避开那些促进肌肉增
粗的“危险”因素,健康纤细两不误。
分享到: 新浪微博 人人 豆瓣 QQ空间 腾讯微博
在这个大多数人以瘦为美的年代,“减肥”是女性的口头禅和终生目标。当狠狠节食为
女性带来了健康的损害和对食物变本加厉的渴望后,不少人开始思考新的减肥方式:即
健康有度的饮食下,培养坚持运动的习惯。这样不但对身体健康更有益,减出的体态身
形也更具健康活力之美。但一说到运动,很多女生马上会联想到“可怕”的肌肉,担心
肥是减了但成了肌肉女,失了女性的娇柔。为了运动减肥的宏伟蓝图不致夭折,粉碎机
必须站出来说,练成肌肉女的担忧是完全可以避免的。
肌肉是怎样练成的
肌肉分骨骼肌、平滑肌和心肌三种,这里我们讨论的主要是影响形体的骨骼肌。骨骼肌
的结构如下图所示,每块肌肉都是有许多的肌纤维组成,每个肌纤维实际上都是一个多
核细胞。肌纤维又由许多肌原纤维组成,每条肌原纤维都可分成一节节的肌... 阅读全帖
M**********e
发帖数: 4237
8
来自主题: Soccer版 - 体脂比对运动水平的影响ZZ
How Body Fat Affects Athletic Performance | The Insight
After exhaustive research, Dr. Todd could not find any academic papers that
answered his simple and important question of how body composition affects
athletic performance.
He did learn, however, that the horse racing community understood how adding
weight to a horse would affect the horse’s running speed. In fact, horse
racers had it down to a science.
A race horse is an amazing physical specimen that typically weighs 1300
pounds at around... 阅读全帖
p*x
发帖数: 533
9
来自主题: EnglishChat版 - 有decrementing这样的用法吗
这样的词不是很多嘛-.=
r*z
发帖数: 1679
r****o
发帖数: 1950
11
hehe,
看来这个问题还不是我一个人问。
l***i
发帖数: 632
12
哪有把这个当作动词的
r****o
发帖数: 1950
13
in some computer science papers
l***i
发帖数: 632
14
they misuse the words...
r****o
发帖数: 1950
15
no, the misuse will no longer be a mistake if it is accepted in academia.
l***i
发帖数: 632
16
I am a prescriptivist...
H********g
发帖数: 43926
17
1%对大多数人来说问题不是很大。尤其是如果在几百几千年里慢慢增加到1%,大部分人
可能就适应了。少数人当然是会不适应的。于是造成了新的内需。
Carbon dioxide content in fresh air (averaged between sea-level and 10 kPa
level, i.e., about 30 km (19 mi) altitude) varies between 0.036% (360 ppm)
and 0.041% (410 ppm), depending on the location.[93][clarification needed]
CO2 is an asphyxiant gas and not classified as toxic or harmful in
accordance with Globally Harmonized System of Classification and Labelling
of Chemicals standards of United Nations Economic Commission f... 阅读全帖
A*****t
发帖数: 1594
18
来自主题: Piebridge版 - [俱乐部]也说痛苦 (转载)
however it's hard to find an applicable standard : one hand the dead is your
fellow being; on the other hand he may not be your relative/neighbor/
colleague; third there are multiple decrements each second in the world so
it's interesting how people should react facing death.
s*****g
发帖数: 1055
19
来自主题: EmergingNetworking版 - 网络技术问题
Not at all, when the packet is routed, L2 header are stripped, lot of IP
header fields can be changed, router will decrement IP TTL, depends on
configuration, TOS/DSCP bit can be modified, if it is a NAT device, source/
destination IP addresses can be changed, etc, etc, outbound L2 encap can be
PPP, without IP checksum, how does next hop router know the IP packets'
integrity are maintained?
The same argument applies to why we need TCP/UDP checksum, the whole point of layered TCP/IP is that upp
F****n
发帖数: 3271
20
Thanks.
Distributed counter is similar to what we are doing.
Does Cassandra has transparent support for distributed counters,
i.e., can it declare a column as "counter" type and then increment/decrement
of that column can utilize a distributed counter?

requirement
g*****g
发帖数: 34805
21
That's correct. Keep in mind due to its nature, the counter isn't always
accurate. If your app is very sensitive on that, don't use it.

decrement
w**z
发帖数: 8232
22
Cassandra counter has a lot of issues. it claims that it is fixed in 2.0.x,
research it before using it.

decrement
G****A
发帖数: 4160
23
// main.cpp
// 10005
#include
#include
using namespace std;

class Monitor {
int num;
public:
Monitor() { num = 1; }
// ~Monitor() {cout<<"des11"< void incident() { num++; }
void decrement() { num--;}
void print() { cout<<"The times of incident :"< }
};

class Monitor2 {
Monitor *m;
public:
Monitor2(Monitor * mm): m
c*****z
发帖数: 182
24
来自主题: Programming版 - 一道bit operator面试题
have no idea what coconut is talking about, can you explain clearer?
my version of decrement is :
////////////////////////
temp = 0;
loop(input)
output = temp;
temp++;
end loop
//output should equal input-1
c*****z
发帖数: 182
25
来自主题: Programming版 - 一道bit operator面试题
///subtraction: input varaibles are small and big
/// i assume we already know small < big
result = big;
loop(small)
result = decrement(result);
end loop
c*****z
发帖数: 182
26
来自主题: Programming版 - 一道bit operator面试题
//division i suppose it ask for integer division which means 5/2=2
// input is big and small , do big/small
result = 0;
remainder = big;
loop(remainder)
remainder = subtract(remainder,small);
result ++;
end loop
decrement(result);
//result = big/small
d****p
发帖数: 685
27
来自主题: Programming版 - Interview question: is the following code OK?
你这个例子是典型的shared ptr误用.
both sp1 and sp2 have their internal shared count object and each such
shared count has incremented the ref count to 1
after the current scope goes out, sp2 gets destructed first and its shared
count object decrements the ref count to zero and the p will be deleted.
now sp1 goes out of scope and this repeated again so there is double delete.

次进入自己的dtor。
w*********s
发帖数: 277
28
来自主题: Programming版 - 新手请教:C++ decrement loop
编程新手,请不吝赐教!
for(unsigned int idx = 9; idx >= 0; idx--) {
cout << "index is " << idx << endl;
}
这么简单的都没调通,很郁闷。这个loop不能terminate,即使idx已经是负数了。
最原始的本意是作为vector的index,所以用的vector::size_type,发现不能
terminate,所以就换成unsigned int试试,仍然不terminate。
谢谢指点!
k****n
发帖数: 1334
29
来自主题: Programming版 - 新手请教:C++ decrement loop
unsigned int 不会是负数
把unsigned去掉
w*********s
发帖数: 277
30
来自主题: Programming版 - 新手请教:C++ decrement loop
got it.
thanks.
G****A
发帖数: 4160
31
***************
class UPInt {
public:
UPInt& operator++(); %function F1
const UPInt operator++(); %function F2
...
};
******************
UPInt i;
int a;
++i; %(1)
i++; %(2)

我觉得按照语法,(2)应该call F1;(1)应该no matched function defined. 但实际
(2)call F2, (1)call F1. 请问compiler用什么rule来决定matching的?
希望我的描述还算清楚。
t****t
发帖数: 6806
32
你的描述一点也不清楚, 按你这个描述肯定是编译通不过的. 除了你是在写C++而不是
matlab, 注释应该用//而不是%以外, 这两个overloading也是不能编译的. 如果你不会
抄的话, 还是copy/paste来得比较容易.
G****A
发帖数: 4160
33
这个问题是朋友问我的,所以我也没有source.
但让我confuse的部分是:
如果有一个member function: UPInt& operator++();
那么对于 UPInt A; A++; ++A; which one is a valid call to the member function?
谢谢大牛耐心解释.
i**********e
发帖数: 1145
34
来自主题: Programming版 - const char *p, is it ok to change p[1] ?
Not a stupid question at all. We all learn from asking questions.
p[1] is converted to *(p+1) in compiler.
p is declared as a character pointer to a constant string. Therefore,
although the pointer can be incremented/decremented, it is illegal to use
the pointer to change the data it is pointing to.
f*******n
发帖数: 12623
35
来自主题: Programming版 - 请问C++返回值和返回引用区别
operator++() is for pre-increment (++x)
operator++(int) is for post-increment (x++)
Because both pre and post are unary operators, there is no way to tell them
apart, so C++ made a special case, and post-increment / post-decrement take
an additional int parameter.
Pre-increment returns a reference, because a pre-increment expression is an
lvalue (you can assign to it or take the address of it, etc.). Post-
increment returns a copy, because a post-increment expression is a rvalue.

呢?
a****i
发帖数: 1182
36
你这个例子举的……
i = i + 1; 你知道换一行写
i ++你就非要写在同一行?
i = 1;
i ++;
j = i;
vs
i = 1;
i = i + 1;
j = i;
对理解有什么区别?
要写在同一行,j = i = i + 1; 也不是那么好看吧
然后说的就是 ++ --是 increment 和decrement,
和 i = i + 1, i = i - 1 概念上是有区别的
更不用说 i ++ 和 i2 = i1 + 1的区别了
T********i
发帖数: 2416
37
和你讨论确实有点困难。
这种系统,update和rollback就是每条线一个interlocked decrement/increment。都
是纳秒级别的。每秒钟transaction数量都是上百万的。增加一台server主要是hot
standby打酱油的。
还什么订票第二天查?这是强实时系统。规定的多少毫秒内guarantee有响应的。
这东东你估计都没听说过。
T********i
发帖数: 2416
38
来自主题: Programming版 - goodbug又丢人了
goodbug根本不懂Interlocked Increament/Decrement。连牵狗都不会。
【 goodbug: 】
你错了,票是有限的,不能超卖,所以必须有锁。而且是多车段,多车次的冲突。不过
魏公公号称要单线程搞定,是不用锁。
一台服务期最多可以起多少thread不太了解, 我的一台12个core机器跑500个线程做运
算处理基本就滩了。
假设以500个线程同步来跑就意味着每个线程每秒需要处理1万张票。按照老魏的算法,
说白了每张票就是InterlockedIncreament 的操作,所以问题简化为所有的core能否一
秒处理500万的interlocked increment。我的分析对吗? (数据全都在内存,似乎也没
有地方需要用锁)
n**x
发帖数: 606
39
有冲突。老魏的方法是北京到上海分成20段。要出这张票的条件是没一段都做
interlock.decrement的,每段都通的话这张票就成。剩下的几张票一次类推。 所以基
本上就便成interlocked 1+1了。。
T********i
发帖数: 2416
40
我真难以想象goodbug这个人基本功如此差劲。
丫明显不懂interlock.decrement怎么用。昨天我已经给丫指出来了,丫迄今都不肯牵
狗。
其实Cassandra要是也能实现这个原语primitive,我就不一定和丫赌了。
第一,Cassandra迄今没有这类操作
第二,即使有这类操作,一个变量也不可能达到5M/s。
T********i
发帖数: 2416
41
换做任何一个正常人,说了这些以后,如果看明白interlock.decrement,会连死的心
都有。
当然了,你goodbug不是正常人。
N*n
发帖数: 456
42
goodbug提的是个好问题啊。。
要是decrement到负数,会怎么样?
g*****g
发帖数: 34805
43
And if you decrement at will and rollback when hitting a zero counter.
Lots of requests will fail although there are actually tickets left, just
temporarily booked and released shortly after. No fairness.
a****i
发帖数: 1182
44
你确定这个可以锁票?我有点糊涂了
比如说卖了济南到上海的(T[234], S2),南京到上海区段就也要锁一张(T[234], S6)
简单地 Interlocked.Decrement( T[X234,S2] ) 怕是不行吧?
不需要锁S3, S4, S5....?
联票可能更有问题
T********i
发帖数: 2416
45
来自主题: Programming版 - 做了一个测试
IBM M4 Sandy Bridge Server 8 X 2 = 16 cores.
Linux 3.0.30-rt50.62.el6rt.x86_64 #1 SMP PREEMPT RT Wed May 16 09:42:30 CEST
2012 x86_64 x86_64 x86_64 GNU/Linux
10个core做Interlocked Increment/Decrement。
每个core 142 million OPS / s。
在考虑是不是把我的指标增加到10 million TPS/s?
g*****g
发帖数: 34805
46
来自主题: Programming版 - 老魏,快点做吧,我等烦了
等了三个月,等来几个decrement, 连compare都不做。太监只能做太监版的东西。
g*****g
发帖数: 34805
47
早说能做5M次的decrement不就完了,12306除了计数器啥也不剩了。连超卖都不用管。
T********i
发帖数: 2416
48
来自主题: Programming版 - 搞了半天,有两人是做行为艺术的
别无耻了。你就不能要点脸?
decrement用xadd和cmpexch效果都一样,但是xadd性能好多了,你现在搞明白了么?
在内行面前狡辩,只能让人家更瞧不起你。
g*****g
发帖数: 34805
49
来自主题: Programming版 - 测试用例在此,看还有什么说的。
我早说必须用comp&swap, 魏太监可是拼命嘲笑我。现在该还回去了,他这辈子只能永
远做太监了。comp&swap的性能跟decrement不能比也不用我指出吧。
首页 上页 1 2 3 下页 末页 (共3页)