<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-Hans-CN">
	<id>https://www.33dai.wiki/index.php?action=history&amp;feed=atom&amp;title=05-%E7%AE%97%E6%B3%95%E6%A8%A1%E6%9D%BF%2F04-%E9%AB%98%E7%B2%BE%E5%BA%A6</id>
	<title>05-算法模板/04-高精度 - 版本历史</title>
	<link rel="self" type="application/atom+xml" href="https://www.33dai.wiki/index.php?action=history&amp;feed=atom&amp;title=05-%E7%AE%97%E6%B3%95%E6%A8%A1%E6%9D%BF%2F04-%E9%AB%98%E7%B2%BE%E5%BA%A6"/>
	<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=05-%E7%AE%97%E6%B3%95%E6%A8%A1%E6%9D%BF/04-%E9%AB%98%E7%B2%BE%E5%BA%A6&amp;action=history"/>
	<updated>2026-05-21T00:47:15Z</updated>
	<subtitle>本wiki上该页面的版本历史</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://www.33dai.wiki/index.php?title=05-%E7%AE%97%E6%B3%95%E6%A8%A1%E6%9D%BF/04-%E9%AB%98%E7%B2%BE%E5%BA%A6&amp;diff=351&amp;oldid=prev</id>
		<title>33DAI：​导入1个版本</title>
		<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=05-%E7%AE%97%E6%B3%95%E6%A8%A1%E6%9D%BF/04-%E9%AB%98%E7%B2%BE%E5%BA%A6&amp;diff=351&amp;oldid=prev"/>
		<updated>2026-05-20T18:12:11Z</updated>

		<summary type="html">&lt;p&gt;导入1个版本&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;zh-Hans-CN&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2026年5月20日 (三) 18:12的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&quot; class=&quot;diff-notice&quot; lang=&quot;zh-Hans-CN&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;（没有差异）&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key my_wiki:diff:1.41:old-350:rev-351 --&gt;
&lt;/table&gt;</summary>
		<author><name>33DAI</name></author>
	</entry>
	<entry>
		<id>https://www.33dai.wiki/index.php?title=05-%E7%AE%97%E6%B3%95%E6%A8%A1%E6%9D%BF/04-%E9%AB%98%E7%B2%BE%E5%BA%A6&amp;diff=350&amp;oldid=prev</id>
		<title>-&gt;Importer：​批量导入三三文档</title>
		<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=05-%E7%AE%97%E6%B3%95%E6%A8%A1%E6%9D%BF/04-%E9%AB%98%E7%B2%BE%E5%BA%A6&amp;diff=350&amp;oldid=prev"/>
		<updated>2026-05-20T16:50:33Z</updated>

		<summary type="html">&lt;p&gt;批量导入三三文档&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;zh-Hans-CN&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2026年5月20日 (三) 16:50的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&quot; class=&quot;diff-notice&quot; lang=&quot;zh-Hans-CN&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;（没有差异）&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key my_wiki:diff:1.41:old-251:rev-350 --&gt;
&lt;/table&gt;</summary>
		<author><name>-&gt;Importer</name></author>
	</entry>
	<entry>
		<id>https://www.33dai.wiki/index.php?title=05-%E7%AE%97%E6%B3%95%E6%A8%A1%E6%9D%BF/04-%E9%AB%98%E7%B2%BE%E5%BA%A6&amp;diff=251&amp;oldid=prev</id>
		<title>33DAI：​导入1个版本</title>
		<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=05-%E7%AE%97%E6%B3%95%E6%A8%A1%E6%9D%BF/04-%E9%AB%98%E7%B2%BE%E5%BA%A6&amp;diff=251&amp;oldid=prev"/>
		<updated>2026-05-20T16:25:34Z</updated>

		<summary type="html">&lt;p&gt;导入1个版本&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;zh-Hans-CN&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2026年5月20日 (三) 16:25的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&quot; class=&quot;diff-notice&quot; lang=&quot;zh-Hans-CN&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;（没有差异）&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key my_wiki:diff:1.41:old-250:rev-251 --&gt;
&lt;/table&gt;</summary>
		<author><name>33DAI</name></author>
	</entry>
	<entry>
		<id>https://www.33dai.wiki/index.php?title=05-%E7%AE%97%E6%B3%95%E6%A8%A1%E6%9D%BF/04-%E9%AB%98%E7%B2%BE%E5%BA%A6&amp;diff=250&amp;oldid=prev</id>
		<title>-&gt;Importer：​批量导入三三文档</title>
		<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=05-%E7%AE%97%E6%B3%95%E6%A8%A1%E6%9D%BF/04-%E9%AB%98%E7%B2%BE%E5%BA%A6&amp;diff=250&amp;oldid=prev"/>
		<updated>2026-05-20T16:22:29Z</updated>

		<summary type="html">&lt;p&gt;批量导入三三文档&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
== 封装好的结构体 ==&lt;br /&gt;
&lt;br /&gt;
实现的内容：&lt;br /&gt;
&lt;br /&gt;
- &amp;lt;code&amp;gt;BigIntTiny a;&amp;lt;/code&amp;gt;：定义一个初始为 &amp;lt;math&amp;gt;0&amp;lt;/math&amp;gt; 的大整数&lt;br /&gt;
- &amp;lt;code&amp;gt;BigIntTiny a = 33;&amp;lt;/code&amp;gt;：通过 &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; 初始化&lt;br /&gt;
- &amp;lt;code&amp;gt;BigIntTiny a = s;&amp;lt;/code&amp;gt;：通过 &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; 初始化&lt;br /&gt;
- &amp;lt;code&amp;gt;a.get_pos(pos)&amp;lt;/code&amp;gt;：获取第 &amp;lt;code&amp;gt;pos&amp;lt;/code&amp;gt; 位的数位内容&lt;br /&gt;
- &amp;lt;code&amp;gt;a.to_str()&amp;lt;/code&amp;gt;：得到对应的字符串，一般用来输出&lt;br /&gt;
- &amp;lt;code&amp;gt;a = -a;&amp;lt;/code&amp;gt;：取反&lt;br /&gt;
- &amp;lt;code&amp;gt;a &amp;lt; b&amp;lt;/code&amp;gt;、&amp;lt;code&amp;gt;a == b&amp;lt;/code&amp;gt;：比较大小&lt;br /&gt;
- &amp;lt;code&amp;gt;a + b&amp;lt;/code&amp;gt;、&amp;lt;code&amp;gt;a - b&amp;lt;/code&amp;gt;、&amp;lt;code&amp;gt;a * b&amp;lt;/code&amp;gt;、&amp;lt;code&amp;gt;a / b&amp;lt;/code&amp;gt;、&amp;lt;code&amp;gt;a % b&amp;lt;/code&amp;gt;：四则运算&lt;br /&gt;
&lt;br /&gt;
因为定义了 &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; 对高精度的转换，所以加减乘除都能直接高精对低精运算。&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
struct BigIntTiny&lt;br /&gt;
{&lt;br /&gt;
    int sign;&lt;br /&gt;
    std::vector&amp;lt;int&amp;gt; v;&lt;br /&gt;
&lt;br /&gt;
    BigIntTiny() : sign(1) {}&lt;br /&gt;
    BigIntTiny(const std::string &amp;amp;s) { *this = s; }&lt;br /&gt;
    BigIntTiny(int v)&lt;br /&gt;
    {&lt;br /&gt;
        char buf[21];&lt;br /&gt;
        sprintf(buf, &amp;quot;%d&amp;quot;, v);&lt;br /&gt;
        *this = buf;&lt;br /&gt;
    }&lt;br /&gt;
    void zip(int unzip)&lt;br /&gt;
    {&lt;br /&gt;
        if (unzip == 0)&lt;br /&gt;
        {&lt;br /&gt;
            for (int i = 0; i &amp;lt; (int)v.size(); i++)&lt;br /&gt;
                v[i] = get_pos(i * 4) + get_pos(i * 4 + 1) * 10 + get_pos(i * 4 + 2) * 100 + get_pos(i * 4 + 3) * 1000;&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
            for (int i = (v.resize(v.size() * 4), (int)v.size() - 1), a; i &amp;gt;= 0; i--)&lt;br /&gt;
                a = (i % 4 &amp;gt;= 2) ? v[i / 4] / 100 : v[i / 4] % 100, v[i] = (i &amp;amp; 1) ? a / 10 : a % 10;&lt;br /&gt;
        setsign(1, 1);&lt;br /&gt;
    }&lt;br /&gt;
    int get_pos(unsigned pos) const { return pos &amp;gt;= v.size() ? 0 : v[pos]; }&lt;br /&gt;
    BigIntTiny &amp;amp;setsign(int newsign, int rev)&lt;br /&gt;
    {&lt;br /&gt;
        for (int i = (int)v.size() - 1; i &amp;gt; 0 &amp;amp;&amp;amp; v[i] == 0; i--)&lt;br /&gt;
            v.erase(v.begin() + i);&lt;br /&gt;
        sign = (v.size() == 0 || (v.size() == 1 &amp;amp;&amp;amp; v[0] == 0)) ? 1 : (rev ? newsign * sign : newsign);&lt;br /&gt;
        return *this;&lt;br /&gt;
    }&lt;br /&gt;
    std::string to_str() const&lt;br /&gt;
    {&lt;br /&gt;
        BigIntTiny b = *this;&lt;br /&gt;
        std::string s;&lt;br /&gt;
        for (int i = (b.zip(1), 0); i &amp;lt; (int)b.v.size(); ++i)&lt;br /&gt;
            s += char(*(b.v.rbegin() + i) + &amp;#039;0&amp;#039;);&lt;br /&gt;
        return (sign &amp;lt; 0 ? &amp;quot;-&amp;quot; : &amp;quot;&amp;quot;) + (s.empty() ? std::string(&amp;quot;0&amp;quot;) : s);&lt;br /&gt;
    }&lt;br /&gt;
    bool absless(const BigIntTiny &amp;amp;b) const&lt;br /&gt;
    {&lt;br /&gt;
        if (v.size() != b.v.size())&lt;br /&gt;
            return v.size() &amp;lt; b.v.size();&lt;br /&gt;
        for (int i = (int)v.size() - 1; i &amp;gt;= 0; i--)&lt;br /&gt;
            if (v[i] != b.v[i])&lt;br /&gt;
                return v[i] &amp;lt; b.v[i];&lt;br /&gt;
        return false;&lt;br /&gt;
    }&lt;br /&gt;
    BigIntTiny operator-() const&lt;br /&gt;
    {&lt;br /&gt;
        BigIntTiny c = *this;&lt;br /&gt;
        c.sign = (v.size() &amp;gt; 1 || v[0]) ? -c.sign : 1;&lt;br /&gt;
        return c;&lt;br /&gt;
    }&lt;br /&gt;
    BigIntTiny &amp;amp;operator=(const std::string &amp;amp;s)&lt;br /&gt;
    {&lt;br /&gt;
        if (s[0] == &amp;#039;-&amp;#039;)&lt;br /&gt;
            *this = s.substr(1);&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
            for (int i = (v.clear(), 0); i &amp;lt; (int)s.size(); ++i)&lt;br /&gt;
                v.push_back(*(s.rbegin() + i) - &amp;#039;0&amp;#039;);&lt;br /&gt;
            zip(0);&lt;br /&gt;
        }&lt;br /&gt;
        return setsign(s[0] == &amp;#039;-&amp;#039; ? -1 : 1, sign = 1);&lt;br /&gt;
    }&lt;br /&gt;
    bool operator&amp;lt;(const BigIntTiny &amp;amp;b) const&lt;br /&gt;
    {&lt;br /&gt;
        return sign != b.sign ? sign &amp;lt; b.sign : (sign == 1 ? absless(b) : b.absless(*this));&lt;br /&gt;
    }&lt;br /&gt;
    bool operator==(const BigIntTiny &amp;amp;b) const { return v == b.v &amp;amp;&amp;amp; sign == b.sign; }&lt;br /&gt;
    BigIntTiny &amp;amp;operator+=(const BigIntTiny &amp;amp;b)&lt;br /&gt;
    {&lt;br /&gt;
        if (sign != b.sign)&lt;br /&gt;
            return *this = (*this) - -b;&lt;br /&gt;
        v.resize(std::max(v.size(), b.v.size()) + 1);&lt;br /&gt;
        for (int i = 0, carry = 0; i &amp;lt; (int)b.v.size() || carry; i++)&lt;br /&gt;
        {&lt;br /&gt;
            carry += v[i] + b.get_pos(i);&lt;br /&gt;
            v[i] = carry % 10000, carry /= 10000;&lt;br /&gt;
        }&lt;br /&gt;
        return setsign(sign, 0);&lt;br /&gt;
    }&lt;br /&gt;
    BigIntTiny operator+(const BigIntTiny &amp;amp;b) const&lt;br /&gt;
    {&lt;br /&gt;
        BigIntTiny c = *this;&lt;br /&gt;
        return c += b;&lt;br /&gt;
    }&lt;br /&gt;
    void add_mul(const BigIntTiny &amp;amp;b, int mul)&lt;br /&gt;
    {&lt;br /&gt;
        v.resize(std::max(v.size(), b.v.size()) + 2);&lt;br /&gt;
        for (int i = 0, carry = 0; i &amp;lt; (int)b.v.size() || carry; i++)&lt;br /&gt;
        {&lt;br /&gt;
            carry += v[i] + b.get_pos(i) * mul;&lt;br /&gt;
            v[i] = carry % 10000, carry /= 10000;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    BigIntTiny operator-(const BigIntTiny &amp;amp;b) const&lt;br /&gt;
    {&lt;br /&gt;
        if (sign != b.sign)&lt;br /&gt;
            return (*this) + -b;&lt;br /&gt;
        if (absless(b))&lt;br /&gt;
            return -(b - *this);&lt;br /&gt;
        BigIntTiny c;&lt;br /&gt;
        for (int i = 0, borrow = 0; i &amp;lt; (int)v.size(); i++)&lt;br /&gt;
        {&lt;br /&gt;
            borrow += v[i] - b.get_pos(i);&lt;br /&gt;
            c.v.push_back(borrow);&lt;br /&gt;
            c.v.back() -= 10000 * (borrow &amp;gt;&amp;gt;= 31);&lt;br /&gt;
        }&lt;br /&gt;
        return c.setsign(sign, 0);&lt;br /&gt;
    }&lt;br /&gt;
    BigIntTiny operator*(const BigIntTiny &amp;amp;b) const&lt;br /&gt;
    {&lt;br /&gt;
        if (b &amp;lt; *this)&lt;br /&gt;
            return b * *this;&lt;br /&gt;
        BigIntTiny c, d = b;&lt;br /&gt;
        for (int i = 0; i &amp;lt; (int)v.size(); i++, d.v.insert(d.v.begin(), 0))&lt;br /&gt;
            c.add_mul(d, v[i]);&lt;br /&gt;
        return c.setsign(sign * b.sign, 0);&lt;br /&gt;
    }&lt;br /&gt;
    BigIntTiny operator/(const BigIntTiny &amp;amp;b) const&lt;br /&gt;
    {&lt;br /&gt;
        BigIntTiny c, d;&lt;br /&gt;
        d.v.resize(v.size());&lt;br /&gt;
        double db = 1.0 / (b.v.back() + (b.get_pos((unsigned)b.v.size() - 2) / 1e4) +&lt;br /&gt;
                           (b.get_pos((unsigned)b.v.size() - 3) + 1) / 1e8);&lt;br /&gt;
        for (int i = (int)v.size() - 1; i &amp;gt;= 0; i--)&lt;br /&gt;
        {&lt;br /&gt;
            c.v.insert(c.v.begin(), v[i]);&lt;br /&gt;
            int m = (int)((c.get_pos((int)b.v.size()) * 10000 + c.get_pos((int)b.v.size() - 1)) * db);&lt;br /&gt;
            c = c - b * m, d.v[i] += m;&lt;br /&gt;
            while (!(c &amp;lt; b))&lt;br /&gt;
                c = c - b, d.v[i] += 1;&lt;br /&gt;
        }&lt;br /&gt;
        return d.setsign(sign * b.sign, 0);&lt;br /&gt;
    }&lt;br /&gt;
    BigIntTiny operator%(const BigIntTiny &amp;amp;b) const { return *this - *this / b * b; }&lt;br /&gt;
    bool operator&amp;gt;(const BigIntTiny &amp;amp;b) const { return b &amp;lt; *this; }&lt;br /&gt;
    bool operator&amp;lt;=(const BigIntTiny &amp;amp;b) const { return !(b &amp;lt; *this); }&lt;br /&gt;
    bool operator&amp;gt;=(const BigIntTiny &amp;amp;b) const { return !(*this &amp;lt; b); }&lt;br /&gt;
    bool operator!=(const BigIntTiny &amp;amp;b) const { return !(*this == b); }&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 例子 ==&lt;br /&gt;
&lt;br /&gt;
=== 阶乘和 ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    int n;&lt;br /&gt;
    cin &amp;gt;&amp;gt; n;&lt;br /&gt;
    BigIntTiny sum = 0;&lt;br /&gt;
    BigIntTiny now = 1;&lt;br /&gt;
    for (int i = 1; i &amp;lt;= n; i++)&lt;br /&gt;
    {&lt;br /&gt;
        now = now * i;&lt;br /&gt;
        sum += now;&lt;br /&gt;
    }&lt;br /&gt;
    cout &amp;lt;&amp;lt; sum.to_str();&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 高精度加法 ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string t;&lt;br /&gt;
BigIntTiny a, b;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    cin &amp;gt;&amp;gt; t; a = t;&lt;br /&gt;
    cin &amp;gt;&amp;gt; t; b = t;&lt;br /&gt;
    cout &amp;lt;&amp;lt; (a + b).to_str();&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:算法模板]]&lt;br /&gt;
[[Category:三三文档]]&lt;/div&gt;</summary>
		<author><name>-&gt;Importer</name></author>
	</entry>
</feed>