0分求调
查看原帖
0分求调
792595
wbw_121124楼主2024/8/13 21:47
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+5;
namespace long_int {
	struct long_int {
		vector<short>a;
		stack<short>st;
		long_int()
		{
			a.push_back(0);
			return;
		}
		const int size() const
		{
			return (int)a.size();
		}
		long_int operator+(const long_int& u) const
		{
			long_int tmp;
			int us = u.size(), ts = this->size(), len = max(us, ts), ln = 1;
			for (int i = 0; i < len; i++)
			{
				if (ln - 1 < i)
					tmp.a.push_back(0), ln++;
				if (us - 1 < i)
					tmp.a[i] += this->a[i];
				else if (ts - 1 < i)
					tmp.a[i] += u.a[i];
				else
					tmp.a[i] += u.a[i] - this->a[i];
				if (tmp.a[i] > 9)
					tmp.a[i] -= 10, tmp.a.push_back(1), ln++;
			}
			return tmp;
		}
		long_int substr(int s, int t, long_int& li = *(new long_int()))
		{
			li.a.clear();
			t += s;
			const int& len = this->size();
			for(int i = len - t; i < len - s; i++)
				li.a.push_back(this->a[i]);
			return li;
		}
	};
	basic_istream<char, char_traits<char>>&
		operator>>(basic_istream<char, char_traits<char>>& in, long_int& a)
	{
		a.a.clear();
		char c;
		in.get(c);
		while ((c == '0' || c == ' ' || c == '\n' || c == '\r') && !in.eof())
			in.get(c);
		while (c >= '0' && c <= '9' && !in.eof())
		{
			a.st.push(c - '0');
			in.get(c);
		}
		if (!in.eof())
			in.unget();
		if (a.st.empty())
			a.a.push_back(0);
		while (!a.st.empty())
		{
			a.a.push_back(a.st.top());
			a.st.pop();
		}
		return in;
	}
	basic_ostream<char, char_traits<char>>&
		operator<<(basic_ostream<char, char_traits<char>>& out, const long_int& a)
	{
		for (int i = a.a.size() - 1; i >= 0; i--)
			out << a.a[i];
		return out;
	}
}
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	long_int::long_int a,b;
	cin>>a>>b;
	cout<<a+b;
	return 0 ;
}
2024/8/13 21:47
加载中...