csp rp++
  • 板块灌水区
  • 楼主WOL_GO
  • 当前回复6
  • 已保存回复6
  • 发布时间2023/9/15 18:22
  • 上次更新2023/11/2 20:42:56
查看原帖
csp rp++
999081
WOL_GO楼主2023/9/15 18:22

rt,

csp初赛rp++

#include<bits/stdc++.h>
using namespace std;
static const int LEN = 1e7+5;
struct high {
	static const int BIT = 9;
	static const int MOD = 1000000000;
	long long s[LEN];
	bool flag;
	high() {
		memset(s,0, sizeof(s));
		flag = s[0] = 1;
	}
	void init() {
		memset(s, 0, sizeof(s));
		s[0] = 1;
	}
	high operator = (const char *num) {
		int l = strlen(num);
		s[0] = 0;
		for(int i = l - 1; i >= 0; i -= BIT) {
			++s[0];
			long long w = 1;
			for(int j = i; j > i - BIT && j >= 0; j--) {
				s[s[0]] += (num[j] ^ 48) * w;
				w = (w << 1) + (w << 3);
			}
		}
		return *this;
	}
	high operator = (const int num) {
		char a[LEN];
		sprintf(a, "%d", num);
		*this = a;
		return *this;
	}
	high(int num) { *this = num; }
	high(const char *num) { *this = num; }

	high operator + (const high &a) {
		high c;
		int x = 0;
		c.s[0] = max(a.s[0], s[0]) + 1;
		for(int i = 1; i <= c.s[0]; i++) {
			c.s[i] = a.s[i] + s[i] + x;
			x = c.s[i] / MOD;
			c.s[i] %= MOD;
		}
		while(c.s[c.s[0]] == 0 && c.s[0] > 1) c.s[0]--;
		return c;
	}
	high operator += (const high &a) {
		*this = *this + a;
		return *this;
	}
	bool operator == (const high &a) {
		int up = max(s[0], a.s[0]);
		for(int i = 0; i < up; i++)
			if(s[up - i] != a.s[up - i]) return false;
		return true;
	}
	bool operator > (const high &a) {
		if(s[0] != a.s[0]) return s[0] > a.s[0];
		int up = max(s[0], a.s[0]);
		for(int i = 0; i < up; i++)
			if(s[up - i] != a.s[up - i]) return s[up - i] > a.s[up - i];
		return false;
	}
	bool operator < (const high &a) {
		if(s[0] != a.s[0]) return s[0] < a.s[0];
		int up = max(s[0], a.s[0]);
		for(int i = 0; i < up; i++)
			if(s[up - i] != a.s[up - i]) return s[up - i] < a.s[up - i];
		return false;
	}
	bool operator >= (const high &a) {
		if(*this > a || *this == a) return true;
		return false;
	}
	bool operator <= (const high &a) {
		if(*this < a || *this == a) return true;
		return false;
	}

	high operator - (const high &a) {
		high c;
		c.s[0] = max(a.s[0], s[0]) + 1;
		if(*this < a) c.flag = false;
		for(int i = 1; i <= c.s[0]; i++) {
			if(c.flag) c.s[i] += s[i] - a.s[i];
			else c.s[i] += a.s[i] - s[i];
			if(c.s[i] < 0) {
				c.s[i] += MOD;
				c.s[i + 1]--;
			}
		}
		while(c.s[c.s[0]] == 0 && c.s[0] > 1) c.s[0]--;
		return c;
	}
	high operator -= (const high &a) {
		*this = *this - a;
		return *this;
	}
	high operator * (const high &a) {
		high c;
		c.s[0] = s[0] + a.s[0];
		for(int i = 1; i <= s[0]; i++) {
			int x = 0;
			for(int j = 1; j <= a.s[0]; j++) {
				c.s[i + j - 1] += s[i] * a.s[j] + x;
				x = c.s[i + j - 1] / MOD;
				c.s[i + j - 1] %= MOD;
			}
			c.s[i + a.s[0]] = x;
		}
		while(c.s[c.s[0]] > 0) c.s[0]++;
		while(c.s[c.s[0]] == 0 && c.s[0] > 1) c.s[0]--;
		return c;
	}
	high operator *= (const high &a) {
		*this = *this * a;
		return *this;
	}
	high operator << (const int &num) {
		s[0]++;
		for(int i = 1; i <= s[0]; i++) {
			s[i] <<= num;
			if(s[i - 1] >= MOD)
				s[i - 1] -= MOD, ++s[i];
		}
		while(s[s[0]] == 0 && s[0] > 1) s[0]--;
		return *this;
	}
	high operator >> (const int &num) {
		for(int i = s[0]; i >= 1; i--) {
			if((s[i] & 1) && i > 1) s[i - 1] += MOD;
			s[i] >>= num;
		}
		while(s[s[0]] == 0 && s[0] > 1) s[0]--;
		return *this;
	}

	high operator / (const high &k) {
		high c = *this, tmp, lt, a;
		a = k;
		tmp.s[1] = 1;
		while(c >= a) {
			a = a << 1;
			tmp = tmp << 1;
		}
		while(tmp.s[0] > 1 || tmp.s[1]) {
			if(c >= a) {
				c -= a;
				lt += tmp;
			}
			a = a >> 1;
			tmp = tmp >> 1;
		}
		c = lt;
		while(c.s[c.s[0]] == 0 && c.s[0] > 1) c.s[0]--;
		if(c.s[0] < 1) c.s[c.s[0] = 1] = 0;
		return c;
	}
	high operator /= (const high &a) {
		*this = *this / a;
		return *this;
	}
	high operator ++ (int) {
		*this+=1;
		return *this+1;
	}
	high operator -- (int) {
		*this-=1;
		return *this-1;
	}
	high operator % (const high &a) {
		high d = *this, c = *this / a;
		c *= a;
		return d - c;
	}
	high operator %= (const high &a) {
		*this = *this % a;
		return *this;
	}
};
ostream& operator << (ostream &out, const high &a) {
	if(!a.flag) putchar('-');
	printf("%d", a.s[a.s[0]]);
	for(int i = a.s[0] - 1; i >= 1; i--)
		printf("%09d", a.s[i]);
	return out;
}
istream& operator >> (istream &in, high &a) {
	char str[LEN];
	in >> str;
	a = str;
	return in;
}
high rp;
int main(){
    while(1)rp++;
    return 0;
}
2023/9/15 18:22
加载中...