|
[求助]工作中遇到的一个追求速度的算法,国外有人控制在30秒内,我却要6分钟.
二分查找某个数的位置的确很快的。 但我现在的二分是找相邻的两个byte不等. 所以比查找某个数位置的二分要耗时一些。。 现在我是这样做的(假设发现2W和4W的位置不等了): DWORD min = 2W; DWORD max = 4W; if (F(min) != F(max)) //这里只是做为递归的依据, { if ((F(max) == F(max-1)) && (F(max-1) != F(min))) {//说明 max 处相邻的两个是 相等 的,并且 不等于 min的位置处,此时要max设为3W ....小值不变min = 2W,大值 max 为3W后递归.... } if ((F(max) == F(max-1)) && (F(max-1) == F(min))) {//说明 max 处相邻的两个是 相等 的,并且 等于 min处位置的值, ...此时要将 mix 设为3W,max 设为4W(这里的将max设为4W应该可以优化的,因为前面已经读过这里的值)... } if ((F(max) != F(max-1)) && (F(max-1) == F(min))) {//max 不等于 max-1 ,说明找到分隔点了,直接返回max return max } } 我的大致程序就是这样子的。感觉这个算法很迂回, 不行的,因为调用GetPosValue一次只能取一个byte. 如果我能全放到内存里*pBuf++ = GetPosValue(dwPos++); 相当于是全部遍历了一遍 |
|
[求助]工作中遇到的一个追求速度的算法,国外有人控制在30秒内,我却要6分钟.
谢谢你。我用的第一总方法与你提供的思路差不多。 我是用 0 10000 20000 30000 这样的dwPos来累加的。。 我发现现在最耗时的就是二分查找的时候。 如果要生成测试文件很简单。 以2W为基数,用一个1.6W 到 2.3W之间的随机值来写0、1、2、3.生成一个2G的文件就可以了。我这里的数据是在硬件中取的,提供不了伪文件 |
|
[求助]工作中遇到的一个追求速度的算法,国外有人控制在30秒内,我却要6分钟.
多谢天易大侠指点,为了学习二分枚举,我翻了好多ACM题,但发现好多是英文题目。 还在继续google中。。 如果大家还有其它的思路,也来发表发表呀。 |
|
[求助]工作中遇到的一个追求速度的算法,国外有人控制在30秒内,我却要6分钟.
兄弟谢谢你, 我做过这种方案,但有的连续次数不是2W,说不定只有1.3W,那么2W会跳过。 有的连续次数可能会是2.1W。现在最耗时的处理就是这种情况了,因为在这里要用二分。 而且这种情况出现频率非常高。 |
|
[求助]工作中遇到的一个追求速度的算法,国外有人控制在30秒内,我却要6分钟.
格式的确是固定的0、1、2、3组成, 但四个元素的个数并不能确定, 而且每个元素的连续数量不一定相等。 并且调用GetPosValue() 函数,一次只能取一个位置的值。 |
|
[讨论]C语言之父Dennis Ritchie去世
致敬。。。。。。。。。 |
|
|
|
[求助]工作中遇到的一个追求速度的算法,国外有人控制在30秒内,我却要6分钟.
没有这种最极端的情况. 可以保证0、1、2、3每个byte连续出现的个数至少在20000以上. 二分法的确不能保证数据全部正确,但当出现2W个1后面接几百个2的情况,可以忽略掉这几百个2 用write_to_binary_file(GetPosValue(pos++))的确能保证百分百的精度,但那就不存在算法了啊。而且速度就。。。。 |
|
[求助]工作中遇到的一个追求速度的算法,国外有人控制在30秒内,我却要6分钟.
其实我也蛮希望S大来关照一下哈。。什么算法对S牛来说都是浮云。。。。我对S牛的膜拜用登峰造极都形容不过来。。。。 |
|
[原创][修改]打造自己的反汇编引擎
把前面的贴也看了一篇,很有意思,慢慢琢磨代码。 |
|
|
|
[求助]工作中遇到的一个追求速度的算法,国外有人控制在30秒内,我却要6分钟.
黑盒中的数据是不透明的。你想获取某处的数据只有通过调用函数GetPosValue。而且一次只能获取一个byte. |
|
[求助]工作中遇到的一个追求速度的算法,国外有人控制在30秒内,我却要6分钟.
目前是采用的二分法.但我发觉2分的效率还不是蛮高的。 |
|
[求助]工作中遇到的一个追求速度的算法,国外有人控制在30秒内,我却要6分钟.
恩,黑盒中的每个位置都是一个byte.. 我的方法:(GetPosValue的参数按以下规律来获取黑盒中的数据) 0 //在这里取的是0 20 40 80 160 320 640 //如果在这里发现取的是1,与前面的不一样了,那么就从320到640之间采用二分法来找相邻的位置 另一种方法(也是按以下规律来获取黑盒中数据): 0 //在这里取的是0 1000 2000 3000 4000 //在这里取的是1,与前面不一样了,那么就从3000到4000之间用二分法。 两者速度差不多。 还一种思路,没写出代码,感觉速度也不快。 还是按 20 40 80 160 320 发现在160和320间不一样了, 于是从160这里开始: 160 160 + 20 160 + 40 160 + 80 160 + 160........ 速度应该更慢。 |
|
|
|
寄存器值保存问题,未解决
直接在代码段找0区, 别在程序段的中间找就可以了,别人做免杀找path位置写代码的时候,一般都是找的下面些的区域。。 |
|
寄存器值保存问题,未解决
path他的程序,,,找一块0区域保存你的值,,想取的时候再拿出来。。。 |
|
|
|
[原创]大四学生,寻找偏系统底层和安全编程的实习
楼主所说的低层有没有一个大概方向呢? 比如某个公司对电脑的某个接口研究的非常深了(非COM或LPT这些接口) 或者对某个硬件的内部物理结构和数据结构研究的非常深了。。。这些算不算低层?? |
操作理由
RANk
{{ user_info.golds == '' ? 0 : user_info.golds }}
雪币
{{ experience }}
课程经验
{{ score }}
学习收益
{{study_duration_fmt}}
学习时长
基本信息
荣誉称号:
{{ honorary_title }}
能力排名:
No.{{ rank_num }}
等 级:
LV{{ rank_lv-100 }}
活跃值:
在线值:
浏览人数:{{ visits }}
最近活跃:{{ last_active_time }}
注册时间:{{ user_info.create_date_jsonfmt }}
勋章
兑换勋章
证书
证书查询 >
能力值