提交记录 31296


用户 题目 状态 得分 用时 内存 语言 代码长度
saffah_dsh_260814 1000i. 【传统题】 A+B Problem Accepted 100 7.41 us 8 KB C 4.91 KB
提交时间 评测时间
2026-08-14 01:21:37 2026-08-14 01:21:50
#include <stdint.h>

struct DuckInfo {
    uint64_t abi_version;
    const char *stdin_ptr;
    uint64_t stdin_size;
    char *stdout_ptr;
    uint64_t stdout_limit;
    uint64_t stdout_size;
    char *stderr_ptr;
    uint64_t stderr_limit;
    uint64_t stderr_size;
    const char *IB_ptr;
    uint64_t IB_limit;
    char *OB_ptr;
    uint64_t OB_limit;
    uint64_t tsc_frequency;
} __attribute__((packed));

int main(int argc, char** argv, char** envp) { return 0; }

static inline int parse_num(const char **pp) {
    const char *p = *pp;
    int neg = 0;
    if (*p == '-') { neg = 1; p++; }
    int v = 0;
    while (*p >= '0' && *p <= '9') { v = v*10 + (*p-'0'); p++; }
    if (neg) v = -v;
    *pp = p;
    return v;
}

static inline void emit_fwd(char **oo, int x) {
    char *o = *oo;
    if (x >= 1000000000) {
        *oo = o + 10;
        *o++ = (char)('0' + x/1000000000); x %= 1000000000;
        *o++ = (char)('0' + x/100000000);  x %= 100000000;
        *o++ = (char)('0' + x/10000000);   x %= 10000000;
        *o++ = (char)('0' + x/1000000);    x %= 1000000;
        *o++ = (char)('0' + x/100000);     x %= 100000;
        *o++ = (char)('0' + x/10000);      x %= 10000;
        *o++ = (char)('0' + x/1000);       x %= 1000;
        *o++ = (char)('0' + x/100);        x %= 100;
        *o++ = (char)('0' + x/10);         x %= 10;
        *o++ = (char)('0' + x);
    } else if (x >= 100000000) {
        *oo = o + 9;
        *o++ = (char)('0' + x/100000000);  x %= 100000000;
        *o++ = (char)('0' + x/10000000);   x %= 10000000;
        *o++ = (char)('0' + x/1000000);    x %= 1000000;
        *o++ = (char)('0' + x/100000);     x %= 100000;
        *o++ = (char)('0' + x/10000);      x %= 10000;
        *o++ = (char)('0' + x/1000);       x %= 1000;
        *o++ = (char)('0' + x/100);        x %= 100;
        *o++ = (char)('0' + x/10);         x %= 10;
        *o++ = (char)('0' + x);
    } else if (x >= 10000000) {
        *oo = o + 8;
        *o++ = (char)('0' + x/10000000);   x %= 10000000;
        *o++ = (char)('0' + x/1000000);    x %= 1000000;
        *o++ = (char)('0' + x/100000);     x %= 100000;
        *o++ = (char)('0' + x/10000);      x %= 10000;
        *o++ = (char)('0' + x/1000);       x %= 1000;
        *o++ = (char)('0' + x/100);        x %= 100;
        *o++ = (char)('0' + x/10);         x %= 10;
        *o++ = (char)('0' + x);
    } else if (x >= 1000000) {
        *oo = o + 7;
        *o++ = (char)('0' + x/1000000);    x %= 1000000;
        *o++ = (char)('0' + x/100000);     x %= 100000;
        *o++ = (char)('0' + x/10000);      x %= 10000;
        *o++ = (char)('0' + x/1000);       x %= 1000;
        *o++ = (char)('0' + x/100);        x %= 100;
        *o++ = (char)('0' + x/10);         x %= 10;
        *o++ = (char)('0' + x);
    } else if (x >= 100000) {
        *oo = o + 6;
        *o++ = (char)('0' + x/100000);     x %= 100000;
        *o++ = (char)('0' + x/10000);      x %= 10000;
        *o++ = (char)('0' + x/1000);       x %= 1000;
        *o++ = (char)('0' + x/100);        x %= 100;
        *o++ = (char)('0' + x/10);         x %= 10;
        *o++ = (char)('0' + x);
    } else if (x >= 10000) {
        *oo = o + 5;
        *o++ = (char)('0' + x/10000);      x %= 10000;
        *o++ = (char)('0' + x/1000);       x %= 1000;
        *o++ = (char)('0' + x/100);        x %= 100;
        *o++ = (char)('0' + x/10);         x %= 10;
        *o++ = (char)('0' + x);
    } else if (x >= 1000) {
        *oo = o + 4;
        *o++ = (char)('0' + x/1000);       x %= 1000;
        *o++ = (char)('0' + x/100);        x %= 100;
        *o++ = (char)('0' + x/10);         x %= 10;
        *o++ = (char)('0' + x);
    } else if (x >= 100) {
        *oo = o + 3;
        *o++ = (char)('0' + x/100);        x %= 100;
        *o++ = (char)('0' + x/10);         x %= 10;
        *o++ = (char)('0' + x);
    } else if (x >= 10) {
        *oo = o + 2;
        *o++ = (char)('0' + x/10);         x %= 10;
        *o++ = (char)('0' + x);
    } else {
        *oo = o + 1;
        *o++ = (char)('0' + x);
    }
}

int __libc_start_main(
    int (*mainp)(int,char**,char**), int argc, char** argv,
    void (*init)(void), void (*fini)(void), void (*rtld_fini)(void))
{
    (void)mainp;(void)init;(void)fini;(void)rtld_fini;
    char **envp = argv + argc + 1;
    while (*envp) envp++;
    unsigned long *auxv = (unsigned long*)(envp + 1);
    struct DuckInfo *d = 0;
    for (; auxv[0] != 0; auxv += 2) {
        if (auxv[0] == 0x6b637564) { d = (struct DuckInfo*)auxv[1]; break; }
    }
    const char *p = d->stdin_ptr;
    int nn = parse_num(&p);
    p++;
    char *o = d->stdout_ptr;
    for (int i = 0; i < nn; i++) {
        int a = parse_num(&p);
        p++;
        int b = parse_num(&p);
        p++;
        int s = a + b;
        if (s < 0) { *o++ = '-'; s = -s; }
        emit_fwd(&o, s);
        *o++ = '\n';
    }
    d->stdout_size = (uint64_t)(o - d->stdout_ptr);
    __asm__ volatile("syscall" : : "a"(60), "D"(0) : "rcx", "r11", "memory");
    return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #17.41 us8 KBAcceptedScore: 100


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