10 条题解

  • 15
    @ 2022-3-26 16:30:55

    来点汇编 (

    C++

    #include <iostream>
    
    int main() {
        int a, b, c1, c2, c3;
        std::cin >> a >> b;
        __asm__(
            "movl %1, %%eax\n\t"
            "movl %2, %%ebx\n\t"
            "addl %%ebx, %%eax\n\t"
            "movl %%eax, %0\n\t"
            : "=r"(c1)
            : "r"(a), "r"(b)
            : "%eax");
        __asm__(
            "movl %1, %%eax\n\t"
            "movl %2, %%ebx\n\t"
            "subl %%ebx, %%eax\n\t"
            "movl %%eax, %0\n\t"
            : "=r"(c2)
            : "r"(a), "r"(b)
            : "%eax");
        __asm__(
            "movl %1, %%eax\n\t"
            "movl %2, %%ebx\n\t"
            "imull %%ebx, %%eax\n\t"
            "movl %%eax, %0\n\t"
            : "=r"(c3)
            : "r"(a), "r"(b)
            : "%eax");
        std::cout << c1 << " " << c2 << " " << c3;
        return 0;
    }
    

    信息

    ID
    246
    时间
    1000ms
    内存
    256MiB
    难度
    2
    标签
    (无)
    递交数
    254
    已通过
    60
    上传者