由买买提看人间百态

topics

全部话题 - 话题: result2
(共0页)
l*****a
发帖数: 14598
1
First ,i think the issue is that we have int a[998]
a[0]..a[997] store the number from 1..1000,missed 2 and no duplication
The best way from Computer science is below:
###pay attention that a^a=0
int result=0;
for(int i=0;i<997;i++)
{
result = result ^ a[i];
}
for(int i=1;i<1001;i++)
{
result = result ^ i;
}
###then result is just missing number1 ^ missing number2.
since they are different,there must be one digit is not the same of the two
number.
int index=1;
if!(result & 1<阅读全帖
f*******t
发帖数: 7549
2
平衡括号的题可以用贪心法做吧
#include
#include
#include
#include
#define INVALIDCHAR -1
using namespace std;
char *balance(char *str)
{
int len = strlen(str);
if(len < 1)
return NULL;

char *buff = (char*)calloc(len + 1, 1);
stack left;
for(int i = 0; i < len; i++) {
if(str[i] == '(')
left.push(i);
else if(str[i] == ')') {
if(left.empty()) {
buff[i] = INVALIDCHAR;
co... 阅读全帖
o**2
发帖数: 168
3
来自主题: Programming版 - FMP 进驻 Programming 版
会用OO编程的应该就会用FM编程,因为FM可以被当作utilities来用,门坎很低。你只
需要在你需要的地方加一点点FM就可以了。
比如说你有一段程序如下,其中的两个worker objects做的都是耗时的工作。因为是顺
序执行的,程序要花25秒才能到300行。
100 Object result1 = worker1.do10seconds();
200 Object result2 = worker2.do15seconds();
300 makeUseOf(result1, result2);
不管你的整个程序或系统有多大,你可以只在这三行程序上使用FM编程。
// 必要的设置
50 Messenger messenger = new Messenger();
60 messenger.registerReceiver(worker1, "worker1", "do10seconds");
70 messenger.registerReceiver(worker2, "worker2", "do15seconds");
100 IDeferredReturn result1 ... 阅读全帖
b*******l
发帖数: 590
4
来自主题: JobHunting版 - Groupon面筋。。。。
我觉得第三题应该这么做:
首先扔2次不够,因为扔2次的话,组合和概率是这样的:
T T:1/16
T F: 3/16
F T: 3/16
F F: 9/16
没有一种组合可以得到8/16 = 1/2
所以必须扔3次,扔3次的组合和概率是这样的:
T T T: 1/64
T T F: 3/64
T F T: 3/64
T F F: 9/64
F T T: 3/64
F T F: 9/64
F F T: 9/64
F F F: 27/64
这里面有好几个组合可以得到32/64 = 1/2,最简单的是F T T + F F F. 最后我的解法
是:
result1 = rand();
result2 = rand();
result3 = rand();
if (!result1&&result2&&result3 || !result1&&!result2&&!result3)
return true;
else
return false;
扔4次也可以,但是没必要。
哪位大侠指教一下?
gy
发帖数: 620
5
来自主题: Database版 - T-SQL 问题
对了, 你想给@result2赋值不是这么做的, 应该是:
exec sp_randomLettersGenerator @result2 out
或者用:
exec sp_randomLettersGenerator @result1 out
set @result2 = @result1

from
P********l
发帖数: 452
6
来自主题: Programming版 - 春运网站架构之争 MapReduce vs MPI
买一张票的复杂度度是1的话,买两张票的复杂度还是1.
买一张票的时间符合泊松分布,买两张票可能还是泊松分布.(我的排队论学得最烂了)
过程大概是:
p1 = buy ticket 1; //买票1,异步
p2 = buy ticket 2; //买票2,异步
wait(p1, p2).
then(function(result1, result2){ //两张票状态全部返回以后.
if(result1.success && result2.success){ //全买到了
check out.
}else{ //至少一张没买到
if(result1.success){
p3 = (return ticket 1); //退票,异步
}
if(result2.success){
p4 = (return ticket 2); //退票,异步
}
}
}).
always(function(){
//exception.
});
wait(p3).then()
wait(p4).then()
d******k
发帖数: 4295
7
来自主题: Programming版 - 一个dot net浮点运算的问题
这个不是精度的问题,是.net怎么储存double
A mathematical or comparison operation that uses a floating-point number
might not yield the same result if a decimal number is used, because the
binary floating-point number might not equal the decimal number. A previous
example illustrated this by displaying the result of multiplying .1 by 10
and adding .1 times.
When accuracy in numeric operations with fractional values is important, you
can use the Decimal rather than the Double type. When accuracy in numeric
operat... 阅读全帖
g*****g
发帖数: 34805
8
来自主题: Programming版 - FMP 进驻 Programming 版
Future f1 = worker1.do10seconds();
Future 22 = worker2.do15seconds();
Object result1 = f1.get();
Object result2 = f2.get();
makeUseOf(result1, result2);
This is Java built-in. And there's no 50-60-70 registration you had there.
I don't see your example simpler.
l*****k
发帖数: 587
9
来自主题: Statistics版 - sas proc transpose
An issue that must have an elegant and simply solution.
I am trying to use transpose on a dataset, however how do
I specify all the variables?
if the are named col1, col1, etc, it is ok to use: var col1-col99
however what if they have random names, I have been trying to export
the data to excel, copy the header(variable name), then paste it back
to sas like
proc transpose data=original out=out;
var test1 result2 test2 result2........;
run;
is there a way to do this without specifying all
g**********1
发帖数: 1113
10
来自主题: JobHunting版 - 做题
先把数除3,遍历result1 to 9,然后这个过程中,把(total- count)/2,遍历
result2 to count.也就是说,先确定最大的数的范围,然后确定其次大的数的范围,
然后随便遍历一下,就都出来了,可以把结果存在一个2维数组里面。
a*******g
发帖数: 867
11
http://w3.cbeta.org/result2/normal/X24/0468_001.htm
卍新纂續藏經 第二十四冊
No. 468《金剛經註解》
六祖曰。修行人亦有四相。
心有能所。輕慢眾生。名我相。
自恃持戒。輕破戒者。名人相。
厭三塗苦。願生諸天。是眾生相。
心愛長年。而勤修福業。法執不忘。是壽者相。
有四相。即是眾生。無四相。即是佛。
S**U
发帖数: 7025
12
比对佛教人物的年代,可以发现某事说法是否可信。以下为最近读书发现的两个疑问。
求那跋陀罗(394年-468年),又译为求那跋多罗,意译为功\\德贤,印度佛教高僧、翻译师。南北朝元嘉十二年(435年)到广州,当时宋文帝刘义隆派人迎至建康,并集力先后译出《杂阿含经》、《楞伽经》、《大法鼓经》、《相续解脱经》、《胜鬘师子吼一乘大方便方广经》等,对汉传佛教影响深远。卒于明帝泰始四年(468年),享年七十五。
一、胜天王般若经的梵本
如果采信上述求那跋陀罗的年代,则《大唐内典录》所说∶"『胜天王般若波罗蜜经』的梵本,是于阗沙门求那跋陀,在梁太清二年(西元548年),遇到传给月婆首那。" 就是不可信的,因为西元548年,求那跋陀罗已经去世八十年了。
印顺法师在《初期大乘佛教之起源与开展》中说到此事,写成∶"「胜天王般若」∶...到了陈天嘉六年(西元五六五),月婆首那Upas/u^nya才译为华文,名『胜天王般若波罗蜜经』。这部经的梵本,是于阗沙门求那跋陀Gun!abhadra,在梁太清二年(西元五四八),带到建业来的。" 不知是否意识到年代的问题了。
http://www.yinshun.org.... 阅读全帖
S**U
发帖数: 7025
13
Let's say there are two 求那跋陀罗 (Nobody ever hinted that there were).
佛说树提伽经
宋于阗国三藏求那跋陀罗译
http://www.cbeta.org/result/normal/T14/0540a001.htm
佛说十二头陀经
宋于阗国三藏求那跋陀罗译
http://www.cbeta.org/result2/normal/T17/0783_001.htm
十二品生死经
宋于阗国三藏求那跋陀罗译
http://www.cbeta.org/result/normal/T17/0753_001.htm
So which 求那跋陀罗 translated the above sutras? What do we know about the
so called 求那跋陀罗 that lived to 西元548年 and met 月婆首那? Keep in mind
that 刘宋 ended in 西元479年.
S**U
发帖数: 7025
14
比对佛教人物的年代,可以发现某事说法是否可信。以下为最近读书发现的两个疑问。
求那跋陀罗(394年-468年),又译为求那跋多罗,意译为功\\德贤,印度佛教高僧、翻译师。南北朝元嘉十二年(435年)到广州,当时宋文帝刘义隆派人迎至建康,并集力先后译出《杂阿含经》、《楞伽经》、《大法鼓经》、《相续解脱经》、《胜鬘师子吼一乘大方便方广经》等,对汉传佛教影响深远。卒于明帝泰始四年(468年),享年七十五。
一、胜天王般若经的梵本
如果采信上述求那跋陀罗的年代,则《大唐内典录》所说∶"『胜天王般若波罗蜜经』的梵本,是于阗沙门求那跋陀,在梁太清二年(西元548年),遇到传给月婆首那。" 就是不可信的,因为西元548年,求那跋陀罗已经去世八十年了。
印顺法师在《初期大乘佛教之起源与开展》中说到此事,写成∶"「胜天王般若」∶...到了陈天嘉六年(西元五六五),月婆首那Upas/u^nya才译为华文,名『胜天王般若波罗蜜经』。这部经的梵本,是于阗沙门求那跋陀Gun!abhadra,在梁太清二年(西元五四八),带到建业来的。" 不知是否意识到年代的问题了。
http://www.yinshun.org.... 阅读全帖
S**U
发帖数: 7025
15
Let's say there are two 求那跋陀罗 (Nobody ever hinted that there were).
佛说树提伽经
宋于阗国三藏求那跋陀罗译
http://www.cbeta.org/result/normal/T14/0540a001.htm
佛说十二头陀经
宋于阗国三藏求那跋陀罗译
http://www.cbeta.org/result2/normal/T17/0783_001.htm
十二品生死经
宋于阗国三藏求那跋陀罗译
http://www.cbeta.org/result/normal/T17/0753_001.htm
So which 求那跋陀罗 translated the above sutras? What do we know about the
so called 求那跋陀罗 that lived to 西元548年 and met 月婆首那? Keep in mind
that 刘宋 ended in 西元479年.
g***t
发帖数: 2278
16
如此众生,身恶行成就,口恶行成就,意恶行成就,谤圣人,邪见受邪法因缘故,身坏
命终,生恶趣泥犁中
(雜阿含經卷第三十一)
http://www.cbeta.org/result2/normal/T02/0099_031.htm
意解脱不满足、慧解脱不满足故,则为谤圣邪见;邪见因缘故,身坏命终,生恶趣泥犁
中。
(雜阿含經卷第三十二)
http://www.cbeta.org/result/normal/T02/0099_032.htm
瞿波梨比丘已怀恶心。谤舍利弗.目犍连。身坏命终。堕此钵头摩地狱中。
(佛說長阿含經卷第十九, 第四分世記經地獄品第四)
http://www.cbeta.org/result/normal/T01/0001_019.htm
若此眾生成就身惡行,口、意惡行,誹謗聖人,邪見成就邪見業,彼因緣此,身壞命終
,必至惡處,生地獄中。
(中阿含王相應品,天使經第七)
http://www.cbeta.org/result/normal/T01/0026_012.htm
梵志因增上慢转生为狗
(中阿含經卷第四十四,鸚鵡經第九)
http://www.cbeta.org... 阅读全帖
o**2
发帖数: 168
17
来自主题: Programming版 - FMP 进驻 Programming 版
更正一下: 程序能立即到300行,但result1.get()要10秒才能返回, result2.get()要
等15秒。因为是并发的,所以一共要15秒,makeUseOf()就能有两个值ready了。
c****e
发帖数: 1453
18
来自主题: Programming版 - FMP 进驻 Programming 版
你这个get和java的future是一样的,都是block的?C# await有个很大的benefit就是
continuation.Task没有执行完也马上返回:
如果makeUseOf(result1.get(), result2.get())是个很大的函数:
result1要很久才用到,get()如果一block, 要等25秒才能进makeUseOf?

classes;
o**2
发帖数: 168
19
来自主题: Programming版 - FMP 进驻 Programming 版
理论上result1.get()和result2.get()是并发的,你只要等最长的那个(也就是15秒)
结束,就可以进入makeUseOf()了。
(共0页)