Why CE

P1001 A+B Problem

int_stl @ 2024-08-06 10:17:35

rt,本地能过编,使用的是 Dev-C++。

#include <bits/stdc++.h>
using namespace std;
int A, B, res;
int main() {
    cin >> A >> B;
    asm(
        "movl %1, %%eax;"   
        "addl %2, %%eax;"   
        "movl %%eax, %0;"  
        : "=r" (res)    
        : "r" (A), "r" (B) 
        : "%eax"   
    );
    cout << res;
    return 0;
}

by LIONELMESSIYYDS @ 2024-08-06 10:19:07

你就非得把简单的问题复杂化吗?


by SegmentTree_ @ 2024-08-06 10:19:55

落谷禁了内联汇编


by Po7ed @ 2024-08-06 10:20:24

比赛不是也不能用吗


by haley001 @ 2024-08-06 10:20:28

/tmp/compiler_qdglco6u/src:6:5: 错误:‘asm’在此作用域中尚未声明


by ln001 @ 2024-08-06 10:21:07

落谷禁了内联汇编


by nr0728 @ 2024-08-06 10:24:06

@int_stl 洛谷没有 asm,请使用 __asm__

-    asm(
+    __asm__(

by nr0728 @ 2024-08-06 10:24:27

@ln001 @tianyu_awa 没有


by int_stl @ 2024-08-06 10:29:37

@nr0728 谢谢


by NC20061226 @ 2024-08-06 10:29:38

@int_stl

#include <bits/stdc++.h>
using namespace std;
int A, B, res;
int main() {
    cin>>A>>B;
    __asm__(
        "movl %1, %%eax;"   
        "addl %2, %%eax;"   
        "movl %%eax, %0;"  
        : "=r" (res)    
        : "r" (A), "r" (B) 
        : "%eax"   
    );
    cout<<res;
    return 0;
}

|