a+b problem
2026-04-12 19:22:19
发布于:上海

榜三了?!

榜4了?!

榜5了?!

又上升了一个档次?!

又上升了2个档次?!

上升了一个档次?!

上榜了?!
本期帖子我们讨论:
为何有人把a+b problem弄的复杂会被骂?
没错,这个事情已经在一个月前了,但我还是想讨论这个问题
Example
@主教.蓝慈曾经在帖子发表了a+b problem这个问题为何报错(帖子已不存在),然后这个人把一长串大约几百行的代码发在帖子上,引得其中包括大佬@请输入文本.(@Stars_Seeker认为:“人家也没骂,只是展开了自己的领域罢了”)Eucatastrophe(只是说了几句,并没有实质性)骂了ta,事后ta还发布了另一条帖子(帖子也已不存在)把其中几个人骂ta的给批评了引发ACGO网友们的骂声(骂@主教.蓝慈),后来ta把帖子删了,然后发了条帖子(sorry!!!(new))道歉,这件事最后大家都不再提这件事了
首先一点,a+b problem本身是一个入门的一道题,为什么非要把这个搞到很复杂像是NOI的一道题呢呢?
举个栗子
把这道题搞成
其次,这个问题如果真要问话,就只拿出新手所用的正常的代码块和一串提问的文字(虽然有点离谱),而不是用一大串几百行的代码所提问
再其次,如果你用AI去写代码再去用这不属于你的代码去发帖子骄傲,那有什么意义呢?如果真是自己写的,那你竞赛早就榜一了
以下是我用AI做的这个问题的代码:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <memory>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <queue>
#include <chrono>
#include <random>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstring>
#include <type_traits>
#include <array>
#include <tuple>
#include <optional>
#include <variant>
#include <any>
#include <bitset>
#include <complex>
#include <valarray>
template <typename T>
concept Arithmetic = std::is_arithmetic_v<T>;
template <Arithmetic T>
class BigInteger {
private:
std::vector<int> digits;
bool negative;
void removeLeadingZeros() {
while (digits.size() > 1 && digits.back() == 0) {
digits.pop_back();
}
}
public:
BigInteger() : negative(false) {
digits.push_back(0);
}
BigInteger(T val) {
negative = val < T(0);
T absVal = negative ? -val : val;
if (absVal == T(0)) {
digits.push_back(0);
} else {
while (absVal > T(0)) {
digits.push_back(static_cast<int>(absVal % T(10)));
absVal /= T(10);
}
}
}
BigInteger operator+(const BigInteger& other) const {
if (negative == other.negative) {
BigInteger result;
result.negative = negative;
int carry = 0;
size_t maxLen = std::max(digits.size(), other.digits.size());
for (size_t i = 0; i < maxLen || carry; ++i) {
int sum = carry;
if (i < digits.size()) sum += digits[i];
if (i < other.digits.size()) sum += other.digits[i];
result.digits.push_back(sum % 10);
carry = sum / 10;
}
return result;
}
BigInteger absThis = *this;
absThis.negative = false;
BigInteger absOther = other;
absOther.negative = false;
if (absThis >= absOther) {
BigInteger result = absThis - absOther;
result.negative = negative;
return result;
} else {
BigInteger result = absOther - absThis;
result.negative = other.negative;
return result;
}
}
BigInteger operator-(const BigInteger& other) const {
if (!negative && !other.negative) {
if (*this >= other) {
BigInteger result;
result.negative = false;
int borrow = 0;
for (size_t i = 0; i < digits.size(); ++i) {
int sub = digits[i] - borrow;
if (i < other.digits.size()) sub -= other.digits[i];
if (sub < 0) {
sub += 10;
borrow = 1;
} else {
borrow = 0;
}
result.digits.push_back(sub);
}
result.removeLeadingZeros();
return result;
} else {
BigInteger result = other - *this;
result.negative = true;
return result;
}
}
if (negative && !other.negative) {
BigInteger absThis = *this;
absThis.negative = false;
BigInteger result = absThis - other;
result.negative = true;
return result;
}
if (!negative && other.negative) {
BigInteger absOther = other;
absOther.negative = false;
return *this - absOther;
}
return BigInteger(0);
}
bool operator>=(const BigInteger& other) const {
if (negative != other.negative) return !negative;
if (digits.size() != other.digits.size()) {
return (digits.size() > other.digits.size()) ^ negative;
}
for (size_t i = digits.size(); i-- > 0; ) {
if (digits[i] != other.digits[i]) {
return (digits[i] > other.digits[i]) ^ negative;
}
}
return true;
}
T toValue() const {
T result = 0;
T mult = 1;
for (size_t i = 0; i < digits.size(); ++i) {
result += static_cast<T>(digits[i]) * mult;
mult *= T(10);
}
return negative ? -result : result;
}
};
template <Arithmetic T>
class ThreadSafeCounter {
private:
T value;
std::mutex mtx;
public:
ThreadSafeCounter() : value(0) {}
void add(T delta) {
std::lock_guard<std::mutex> lock(mtx);
value += delta;
}
T get() {
std::lock_guard<std::mutex> lock(mtx);
return value;
}
};
template <typename T>
class BinaryTreeAdder {
private:
struct Node {
T data;
std::unique_ptr<Node> left;
std::unique_ptr<Node> right;
Node(T val) : data(val), left(nullptr), right(nullptr) {}
};
std::unique_ptr<Node> root;
void insert(Node* node, T val) {
if (val < node->data) {
if (node->left) {
insert(node->left.get(), val);
} else {
node->left = std::make_unique<Node>(val);
}
} else {
if (node->right) {
insert(node->right.get(), val);
} else {
node->right = std::make_unique<Node>(val);
}
}
}
T sum(Node* node) {
if (!node) return 0;
return node->data + sum(node->left.get()) + sum(node->right.get());
}
public:
BinaryTreeAdder() {}
void add(T val) {
if (!root) {
root = std::make_unique<Node>(val);
} else {
insert(root.get(), val);
}
}
T total() {
return sum(root.get());
}
};
class MetaAdder {
public:
static constexpr int add(int a, int b) {
return a + b;
}
};
template <size_t N>
class LoopUnroller {
public:
static int add(int a, int b) {
int result = a + b;
for (size_t i = 0; i < N; ++i) {
result += (i - i);
}
return result;
}
};
class CoroutineAdder {
public:
struct promise_type {
int current_value;
CoroutineAdder get_return_object() {
return CoroutineAdder { std::coroutine_handle<promise_type>::from_promise(*this) };
}
std::suspend_never initial_suspend() { return {}; }
std::suspend_never final_suspend() noexcept { return {}; }
void unhandled_exception() {}
void return_value(int val) { current_value = val; }
};
std::coroutine_handle<promise_type> handle;
CoroutineAdder(std::coroutine_handle<promise_type> h) : handle(h) {}
~CoroutineAdder() { if (handle) handle.destroy(); }
int get() { return handle.promise().current_value; }
};
CoroutineAdder makeAdder(int a, int b) {
co_return a + b;
}
template <int N>
struct RecursiveAdder {
static int add(int a, int b) {
return RecursiveAdder<N-1>::add(a, b);
}
};
template <>
struct RecursiveAdder<0> {
static int add(int a, int b) {
return a + b;
}
};
class VirtualFunctionAdder {
public:
virtual int add(int a, int b) {
return a + b;
}
virtual ~VirtualFunctionAdder() = default;
};
class DerivedAdder : public VirtualFunctionAdder {
public:
int add(int a, int b) override {
return a + b;
}
};
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int x, y;
std::cin >> x >> y;
BigInteger<int> bigX(x);
BigInteger<int> bigY(y);
BigInteger<int> bigSum = bigX + bigY;
int result1 = bigSum.toValue();
ThreadSafeCounter<int> counter;
counter.add(x);
counter.add(y);
int result2 = counter.get();
BinaryTreeAdder<int> tree;
tree.add(x);
tree.add(y);
int result3 = tree.total();
int result4 = MetaAdder::add(x, y);
int result5 = LoopUnroller<100>::add(x, y);
CoroutineAdder coro = makeAdder(x, y);
int result6 = coro.get();
int result7 = RecursiveAdder<50>::add(x, y);
VirtualFunctionAdder* vfa = new DerivedAdder();
int result8 = vfa->add(x, y);
delete vfa;
std::vector<std::function<int()>> functions = {
[&]() { return x + y; },
[&]() { return result1; },
[&]() { return result2; },
[&]() { return result3; },
[&]() { return result4; },
[&]() { return result5; },
[&]() { return result6; },
[&]() { return result7; },
[&]() { return result8; }
};
int finalResult = 0;
for (auto& func : functions) {
finalResult = func();
}
std::cout << finalResult << std::endl;
return 0;
}


不MLE能怎么样呢?
没错,大家都是这样弄过来的
所以,我要说一句:
不要用AI的功劳把它发在帖子上骄傲,这本不属于你的
要问问题就好好问,不要用不正常的代码(指的是行数有问题的、搞抽象的)来提问题
(虽然这期很水)
宣传团队位(11位)
| 宣传人 | ID | 团队 |
|---|---|---|
| @斩神者(必回关)目标1000粉 | 5523907 | 斩神队 |
| @ㅤ | 5205178 | 穿越时空ℜ |
| @C++的狗 | 4716113 | 做C++的狗吗(已恢复 |
| @༺ཌༀ刘国安ༀད༻ | 4871337 | 天界四柱·月 |
私信或在评论区发
| 感谢名单 | 事迹 |
|---|---|
| @Stars_Seeker | 指正 |
| Eucatastrophe | 指正 |
全部评论 84
- 置顶
在此感谢@C++的狗为我团队宣传

2026-04-13 来自 浙江
1不用谢
2026-04-13 来自 上海
0
2026-04-13 来自 浙江
0
没有猪脚长
2026-04-10 来自 湖北
10他已经爆帖子最长限制了
2026-04-10 来自 上海
9我真是服了啊,帖子一落千丈,可是点赞数评论数能超过很多
2026-04-10 来自 湖北
8谁啊
2026-04-10 来自 上海
7
这么多代码,我拿去试试
2026-04-10 来自 广东
6骗你的实际上绝对会CE
2026-04-10 来自 上海
3
恭喜榜5
2026-04-11 来自 河北
3%d\n
2026-04-10 来自 河北
3请输入文本:
2026-04-13 来自 浙江
2?
2026-04-13 来自 上海
1感谢你为我团队宣传
2026-04-13 来自 浙江
1
a
2026-04-12 来自 浙江
2a
2026-04-12 来自 浙江
2a
2026-04-12 来自 浙江
2
2026-04-11 来自 浙江
2开光影了
02026-04-12 来自 浙江
0也可能是光追

2026-04-12 来自 浙江
0ddd
2026-04-17 来自 浙江
0
ddd
2026-04-11 来自 上海
2a
2026-04-05 来自 浙江
2a
2026-04-10 来自 浙江
2a
2026-04-10 来自 浙江
2a
2026-04-10 来自 浙江
1
必须点赞
2026-04-13 来自 浙江
1ddd
2026-04-17 来自 浙江
1ddddddd
2026-04-17 来自 浙江
1
oh
2026-04-13 来自 浙江
1d
2026-04-11 来自 山东
1d
2026-04-11 来自 山东
1d
2026-04-11 来自 山东
1互赞拿罐头
2026-04-11 来自 广东
1确实
2026-04-11 来自 四川
1666
2026-04-11 来自 浙江
1




























































有帮助,赞一个