- A + B Problem
代码最长挑战
- 2025-3-31 21:46:52 @
比一比谁的代码更长
我的代码(不是用来比的)
#include <bits/stdc++.h>
using namespace std;
int a, b, c[100], lc = 1;
priority_queue<int> h;
int main() {
scanf("%d%d", &a, &b);
h.push(a);
h.push(b);
memset(c, 0, sizeof(c));
while (!h.empty()) {
int x = h.top();
h.pop();
if (x > 1) {
h.push(x - 1);
h.push(1);
}
else {
c[1] += x;
for (int i = 1; i <= lc; i++) {
c[i + 1] += c[i] / 10;
c[i] %= 10;
}
if (c[lc + 1] > 0)
lc++;
}
}
for (int i = lc; i >= 1; i--)
printf("%d", c[i]);
printf("\n");
return 0;
}
亮出你们的杰作吧!
前提是这段代码能Accepted!
3 条评论
-
胡立言 LV 3 @ 2025-4-2 17:54:08
我是MVP
-
2025-4-2 17:40:30@
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <cmath> #include <thread> #include <chrono> #include <queue> #include <stack> #include <map> #include <set> #include <unordered_map> #include <unordered_set> #include <functional> #include <memory> #include <random> #include <numeric> #include <iomanip> #include <sstream> #include <fstream> #include <cstdio> #include <cstdlib> #include <ctime> #include <cstring> #include <climits> #include <cfloat> #include <cstddef> #include <cstdint> #include <cassert> #include <cwchar> #include <cwctype> #include <exception> #include <stdexcept> #include <typeinfo> #include <type_traits> #include <bitset> #include <complex> #include <valarray> #include <array> #include <forward_list> #include <list> #include <deque> #include <initializer_list> #include <tuple> #include <utility> #include <variant> #include <optional> #include <any> #include <filesystem> #include <regex> #include <atomic> #include <mutex> #include <condition_variable> #include <future> #include <shared_mutex> #include <execution> #include <codecvt> #include <locale> #include <ciso646> #include <cerrno> #include <cfenv> #include <cinttypes> #include <cstdalign> #include <cstdarg> #include <cstdbool> #include <ctgmath> #include <cuchar> #include <limits> #include <ios> #include <iosfwd> #include <istream> #include <ostream> #include <streambuf> #include <sstream> #include <iomanip> #include <bits/stdc++.h> #include <iostream> #include <stack> using namespace std; void do_nothing_1(); void do_nothing_2(int x); int do_nothing_3(int a, int b); long long do_nothing_4(long long x); float do_nothing_5(float a, float b); double do_nothing_6(double x); int unused_var_1 = 0; float unused_var_2 = 3.14; string unused_var_3 = "Hello, World!"; vector<int> unused_var_4 = {1, 2, 3}; map<string, int> unused_var_5 = {{"A", 1}, {"B", 2}}; class UselessClass1 { public: UselessClass1() {} void useless_method_1() {} int useless_method_2(int x) { return x + 1; } }; class UselessClass2 : public UselessClass1 { public: UselessClass2() {} void useless_method_3() {} }; template<typename T> T useless_template(T x) { return x + 1; } #define USELESS_MACRO_1(x) (x + 1) #define USELESS_MACRO_2(x, y) (x + y + 1) int recursive_nonsense(int x) { if (x <= 0) return 0; return recursive_nonsense(x - 1) + 1; } int add_recursive(int x, int y) { if (y == 0) return x; return add_recursive(x ^ y, (x & y) << 1); } int add_with_stack(int a, int b) { stack<int> s; s.push(a); s.push(b); int sum = 0; while (!s.empty()) { sum += s.top(); s.pop(); } return sum; } int main() { int a, b; cin >> a >> b; cout << add_with_stack(a, b) << endl; return 0; }
132行
-
2025-4-1 19:25:15@
#include <algorithm> #include <bitset> #include <cctype> #include <cerrno> #include <clocale> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <exception> #include <fstream> #include <functional> #include <limits> #include <list> #include <map> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <utility> #include <vector> #include <cwchar> #include <cwctype> using namespace std; int a,b; int main() { scanf("%d%d",&a,&b); printf("%d",a+b); return 0; }
43行
- 1
信息
- ID
- 56
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 1
- 标签
- 递交数
- 10229
- 已通过
- 4610
- 上传者