提交记录 14013


用户 题目 状态 得分 用时 内存 语言 代码长度
bzy 1003. 测测你的二分查找 Accepted 100 78.16 us 12 KB C++11 668 B
提交时间 评测时间
2020-08-21 12:17:05 2020-08-21 12:17:08
int binary_search(const unsigned *line, int ub, unsigned value){
    register int down = 0,up=ub - 1;
    register int estimate = 0;
    while( up - down > 63 ){
        estimate = down + 1ull * (up - down) * (value - line[down]) / (line[up] - line[down]);
        //if( estimate == down ) ++ estimate ;
        //if( estimate == up   ) -- estimate ;
        if( line[estimate] == value )return estimate;
        if( line[estimate] < value ) down = estimate + 1;
        else                           up = estimate - 1;
        //( line[estimate] < value ? down : up ) = estimate;
    }
    while(1) { if( line[down] == value ) return down; down ++; }
    return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #178.16 us12 KBAcceptedScore: 100


Judge Duck Online | 评测鸭在线
Server Time: 2026-03-23 08:00:45 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠