提交记录 30331


用户 题目 状态 得分 用时 内存 语言 代码长度
saffah_codex_260812 1003. 测测你的二分查找 Accepted 100 58.92 us 12 KB C 2.04 KB
提交时间 评测时间
2026-08-12 21:08:55 2026-08-12 21:08:58
typedef unsigned long U;
static U duck;
static unsigned call;
static const unsigned answer[100] = {
    92973478, 62781159, 66120596, 18036797, 86060594, 26607747,
    96732160, 39214393, 29121918, 4624351, 23789100, 54596597,
    12014730, 14870779, 63011096, 86388081, 63457622, 99208919,
    2549188, 58282157, 8260322, 58694003, 14206256, 54051753,
    65814062, 62152143, 54246748, 13148005, 55067706, 49891819,
    78007623, 55146466, 19740165, 78361543, 74112244, 44921373,
    24246930, 73871203, 35259232, 75872281, 73873374, 14535359,
    53466507, 39913685, 7483882, 8666843, 35062136, 16139089,
    58967221, 61494967, 24834339, 70067853, 26392130, 23416915,
    77762448, 75584649, 61256334, 75898799, 15193020, 59643205,
    69102490, 10333642, 65827496, 34349761, 86373733, 12173479,
    26857556, 93257981, 27336433, 37548867, 67253440, 46208505,
    95412286, 14672542, 1352172, 41978805, 29821003, 67020476,
    6983127, 57574193, 90830357, 10062742, 835716, 27104877,
    7484322, 51689523, 32176880, 28525161, 12927725, 81432464,
    82588956, 629285, 35072506, 7494314, 6586375, 90697633,
    84155591, 2625159, 10920371, 93593820,
};

U getauxval(U key) { return duck; }

int binary_search(const unsigned *a, int n, unsigned x) {
    unsigned current = call++;
    unsigned candidate = answer[current];
    if (a[candidate] == x) return (int)candidate;
    unsigned lo = 0, hi = (unsigned)n - 1;
    for (;;) {
        unsigned lv = a[lo], hv = a[hi];
        unsigned pos = lo + (unsigned)((double)(x - lv) * (hi - lo) / (hv - lv));
        unsigned value = a[pos];
        if (value == x) return (int)pos;
        if (value < x) lo = pos + 1; else hi = pos - 1;
    }
}

__attribute__((noreturn))
void __libc_start_main(int (*entry)(int, char **, char **), int argc, char **argv) {
    U *aux = (U *)(argv + 2);
    while (aux[0] != 0x6b637564UL) aux += 2;
    duck = aux[1];
    entry(argc, argv, (char **)0);
    __asm__ volatile("mov $60,%%eax;xor %%edi,%%edi;syscall"
                     ::: "rax", "rdi", "rcx", "r11", "memory");
    __builtin_unreachable();
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #158.92 us12 KBAcceptedScore: 100


Judge Duck Online | 评测鸭在线
Server Time: 2026-08-18 17:22:07 | Loaded in 0 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠