跳到正文

题解

题解:A+B problem

Shuhang_JOKER1约 1 分钟
原文
文章信息与版本

文章信息

发布
2025年8月3日
收录
2025年12月12日
更新
2026年11月11日
篇幅
约 1 分钟
获赞
4
题目
P1001

版本

  1. v1当前

看到很多大佬在发题解,我也来一波搜索 ~

话不多说,看题解:

C++
#include <bits/stdc++.h>
using namespace std;
int a, b, ans;
void dfs(int x, int y){
    if(x<0){
        ans+=x;
        x=0;
    }
    if(y<0){
        ans+=y;
        y=0;
    }
    if(x==0&&y==0)
        return;
    ans+=2;
    x--;
    y--;
    dfs(x,y);
}
int main(){
    cin >> a >> b;
    dfs(a,b);
	cout << ans << endl;
	return 0;
}
原文