Why it don't out answer?
查看原帖
Why it don't out answer?
602624
___njr___楼主2023/3/2 13:09
#include<iostream>
#include<string>
#include<vector>
#include<stack>
using namespace std;
typedef unsigned long long u;
const u um = 1e16;
class Big {
		vector<u> val;
		int len;
	public:
//		void operator=(Big other);
//		Big operator+(Big other);
//		Big operator*(Big other);
		Big TB(string tmp) {
			Big other;
			u Tmp;
			int Len = 0 ;
			stack<char>t;
			for(int i = 0 ; i < tmp.size(); ++i)t.push(tmp[i]);
			while(t.size()) {
				Tmp = Tmp<<3+Tmp<<1+(t.top()^48);
				if(Tmp>=um) {
					other.val[Len++] = Tmp;
					Tmp = 0;
				}
			}
			other.len = Len;
			return other;

		}
		void operator=(Big other) {
			len = other.len;
			val.clear();
			for(int i = 0 ; i <len; ++i)val[i] = other.val[i];
		}
		Big operator+(Big other) {
			Big c;
			c.len = max(len , other.len) + 1;
			for(int i = 0 ; i < c.len; ++i)c.val[i] = val[i] + other.val[i];
			for(int i = 0 ; i < c.len; ++i)while(c.val[i]>9) {
					c.val[i]-=10;
					++c.val[i+1];
				}
			while(!c.val[--c.len]);
			++c.len;
			return c;
		}
		Big operator*(Big other) {
			Big c;
			c.len = len+other.len+1;
			for(int i = 0;  i<len; ++i)for(int j = 0 ; j < other.len ; ++j)c.val[i+j]+=val[i]*other.val[j];
			for(int i = 0 ; i<c.len; ++i)while(c.val[i]>9) {
					c.val[i]-=10;
					++c.val[i+1];
				}
			if(!c.val[c.len-1])--len;
			return c;
		}
		void out(Big other) {
			for(int i = 0 ; i < other.len ; ++i)cout<<other.val [i];
		}
		Big in(Big other) {
			string tmp;
			cin>>tmp;
			return TB(tmp);
		}
		bool operator--() {
			if(len == 1 && val[0]==0)return false;
			int i = 0 ;
			while(!val[i])++i;
			--val[i];
			return true;
		}

};
int main() {
	Big n;
	n.in(n);
	Big i = n + n.TB("2") ;
	Big ans = ans.TB("0") ;
	while(--i) {
		ans = ans*i;
		ans = ans+i;
	}
	ans.out(ans); 
	return 0;
}

2023/3/2 13:09
加载中...