MLE了,求优化

P1001 A+B Problem

Rn_Lamsuly @ 2020-11-14 21:13:44

#include<bits/stdc++.h>
using namespace std;
int add(int a,int b)
{
    if(a&b==0)return (a|b);
    return add(a^b,(a&b)<<1);
}
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    printf("%d",add(a,b));
    return 0;
}

by Blood_red @ 2020-12-14 20:51:03

#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c=0;
    cin>>a>>b;
    for(int i=1;i<=10;i++){
        c+=b;
    }
    for(int j=1;j<=10;j++){
        c+=a;
    }
    c/=10;
    cout<<c;
    return 0;
}
//绕弯弯

by xurunsong @ 2020-12-16 18:40:39

int add(int a,int b)
{
    if(a&b==0)return (a|b);
    return add(a^b,(a&b)<<1);
}

这......计算机里0+0=0啊,这一段没必要


by Blood_red @ 2021-02-22 16:58:55

#include <bits/stdc++.h>
using namespace std;
int main() {
    int a,b;
    cin>>a>>b;
    cout<<a+b;
    return 0;
}

这样不香吗???


上一页 |