日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

模板:高精

發布時間:2023/12/3 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 模板:高精 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

想必大家一定都深受高精所害
python黨:啥叫高精?
這里送上一種高精板子 寫法
轉載自巨神wyx的博客

#include <bits/stdc++.h> using namespace std;const int maxn = 1000;struct bign {int d[maxn], len;void clean() {while (len > 1 && !d[len - 1]) len--;}bign() {memset(d, 0, sizeof(d));len = 1;}bign(int num) { *this = num; }bign(char* num) { *this = num; }bign operator=(const char* num) {memset(d, 0, sizeof(d));len = strlen(num);for (int i = 0; i < len; i++) d[i] = num[len - 1 - i] - '0';clean();return *this;}bign operator=(int num) {char s[20];sprintf(s, "%d", num);*this = s;return *this;}bign operator+(const bign& b) {bign c = *this;int i;for (i = 0; i < b.len; i++) {c.d[i] += b.d[i];if (c.d[i] > 9)c.d[i] %= 10, c.d[i + 1]++;}while (c.d[i] > 9) c.d[i++] %= 10, c.d[i]++;c.len = max(len, b.len);if (c.d[i] && c.len <= i)c.len = i + 1;return c;}bign operator-(const bign& b) {bign c = *this;int i;for (i = 0; i < b.len; i++) {c.d[i] -= b.d[i];if (c.d[i] < 0)c.d[i] += 10, c.d[i + 1]--;}while (c.d[i] < 0) c.d[i++] += 10, c.d[i]--;c.clean();return c;}bign operator*(const bign& b) const {int i, j;bign c;c.len = len + b.len;for (j = 0; j < b.len; j++)for (i = 0; i < len; i++) c.d[i + j] += d[i] * b.d[j];for (i = 0; i < c.len - 1; i++) c.d[i + 1] += c.d[i] / 10, c.d[i] %= 10;c.clean();return c;}bign operator/(const bign& b) {int i, j;bign c = *this, a = 0;for (i = len - 1; i >= 0; i--) {a = a * 10 + d[i];for (j = 0; j < 10; j++)if (a < b * (j + 1))break;c.d[i] = j;a = a - b * j;}c.clean();return c;}bign operator%(const bign& b) {int i, j;bign a = 0;for (i = len - 1; i >= 0; i--) {a = a * 10 + d[i];for (j = 0; j < 10; j++)if (a < b * (j + 1))break;a = a - b * j;}return a;}bign operator+=(const bign& b) {*this = *this + b;return *this;}bool operator<(const bign& b) const {if (len != b.len)return len < b.len;for (int i = len - 1; i >= 0; i--)if (d[i] != b.d[i])return d[i] < b.d[i];return false;}bool operator>(const bign& b) const { return b < *this; }bool operator<=(const bign& b) const { return !(b < *this); }bool operator>=(const bign& b) const { return !(*this < b); }bool operator!=(const bign& b) const { return b < *this || *this < b; }bool operator==(const bign& b) const { return !(b < *this) && !(b > *this); }string str() const {char s[maxn] = {};for (int i = 0; i < len; i++) s[len - 1 - i] = d[i] + '0';return s;} };istream& operator>>(istream& in, bign& x) {string s;in >> s;x = s.c_str();return in; }ostream& operator<<(ostream& out, const bign& x) {out << x.str();return out; } int main() {//下面愛咋寫咋寫了bign a, b;cin >> a >> b;if (a >= b) {cout << a;return 0;}cout << b % a;return 0; }

thanks for reading!

總結

以上是生活随笔為你收集整理的模板:高精的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。