关于A+B的题解

P1001 A+B Problem

沉石鱼惊旋 @ 2022-02-26 15:52:37

rt,最后一篇little_gift 的题解排版……建议删除


by LYqwq @ 2022-02-26 15:54:18

我咋感觉大部分都不符合现在的要求...


by 沉石鱼惊旋 @ 2022-02-26 15:56:57

但那篇是最emmm的吧


by 川寰boy @ 2022-02-26 16:27:57

太nb了,用类


by user470883 @ 2022-02-26 16:28:43

@chenyuxuan__2009 建议撤掉所有类似这段代码的题解(:

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int a,b;
    cin >> a >> b;
    cout << a+b << endl;
    return 0;
}

(((


by ZHP20090830 @ 2022-03-05 14:36:45


#include<iostream>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b;
    c=a+b;
    cout<<c;
    return 0;
}

by j1ANGFeng @ 2022-03-05 18:13:02

@ZHP20090830

好厉害啊


by freedom_wang @ 2022-03-08 16:07:05

@chenyuxuan__2009

#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
    int a,b;
    cin >> a >> b;
    if(b<0||a<0){
        for(int i=100000000;1;i--){
            if(i-a==b){cout<<i;return 0;}
        }
    }
    for(int i=1;1;i-=-1){
        if(i-a==b){cout<<i;return 0;}
    }
    return 0;
}

by d2020csr @ 2022-04-10 19:12:06

???


by d2020csr @ 2022-04-10 19:30:41

c++11

运用深搜(伪)解决A+B problem\ 源码如下:

#include<bits/stdc++.h>
using namespace std;
map<int,bool> c;
long long d[114514],bj,a,b,sum;
void dfs(int x){
    for(int i=1;i<=2;i++){
        if(i==1&&bj==0){
            if(c[a]==false){
                c[a]=true;
                d[x]=a;
                dfs(x+1);
                c[a]=false;
            }
        }
        else if(i==2){
            if(c[b]==false){
                c[b]=true;
                d[x]=b;
                dfs(x+1);
                c[b]=false;
            }
        }
    }
    if(x==2){
        for(int k=1;k<=2;k++) sum+=d[k];
        if(sum==a+b&&bj==0){
            bj=1;
            cout<<sum;
        }
        return;
    }
} 
int main(){
    cin>>a>>b;
    dfs(1);
} 

by VictoriaEVA @ 2022-04-16 16:23:10

捂脸...


| 下一页