<?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=06-%E6%95%B0%E5%AD%A6%E7%9B%B8%E5%85%B3%2F08-%E5%BF%AB%E9%80%9F%E5%B9%82%E4%B8%8E%E5%BF%AB%E9%80%9F%E4%B9%98</id>
	<title>06-数学相关/08-快速幂与快速乘 - 版本历史</title>
	<link rel="self" type="application/atom+xml" href="https://www.33dai.wiki/index.php?action=history&amp;feed=atom&amp;title=06-%E6%95%B0%E5%AD%A6%E7%9B%B8%E5%85%B3%2F08-%E5%BF%AB%E9%80%9F%E5%B9%82%E4%B8%8E%E5%BF%AB%E9%80%9F%E4%B9%98"/>
	<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=06-%E6%95%B0%E5%AD%A6%E7%9B%B8%E5%85%B3/08-%E5%BF%AB%E9%80%9F%E5%B9%82%E4%B8%8E%E5%BF%AB%E9%80%9F%E4%B9%98&amp;action=history"/>
	<updated>2026-05-20T23:09:50Z</updated>
	<subtitle>本wiki上该页面的版本历史</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://www.33dai.wiki/index.php?title=06-%E6%95%B0%E5%AD%A6%E7%9B%B8%E5%85%B3/08-%E5%BF%AB%E9%80%9F%E5%B9%82%E4%B8%8E%E5%BF%AB%E9%80%9F%E4%B9%98&amp;diff=375&amp;oldid=prev</id>
		<title>33DAI：​导入1个版本</title>
		<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=06-%E6%95%B0%E5%AD%A6%E7%9B%B8%E5%85%B3/08-%E5%BF%AB%E9%80%9F%E5%B9%82%E4%B8%8E%E5%BF%AB%E9%80%9F%E4%B9%98&amp;diff=375&amp;oldid=prev"/>
		<updated>2026-05-20T18:12:12Z</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;tr class=&quot;diff-title&quot; lang=&quot;zh-Hans-CN&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan=&quot;1&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;2&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;/table&gt;</summary>
		<author><name>33DAI</name></author>
	</entry>
	<entry>
		<id>https://www.33dai.wiki/index.php?title=06-%E6%95%B0%E5%AD%A6%E7%9B%B8%E5%85%B3/08-%E5%BF%AB%E9%80%9F%E5%B9%82%E4%B8%8E%E5%BF%AB%E9%80%9F%E4%B9%98&amp;diff=374&amp;oldid=prev</id>
		<title>-&gt;Importer：​批量导入三三文档</title>
		<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=06-%E6%95%B0%E5%AD%A6%E7%9B%B8%E5%85%B3/08-%E5%BF%AB%E9%80%9F%E5%B9%82%E4%B8%8E%E5%BF%AB%E9%80%9F%E4%B9%98&amp;diff=374&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;tr class=&quot;diff-title&quot; lang=&quot;zh-Hans-CN&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan=&quot;1&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;2&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;/table&gt;</summary>
		<author><name>-&gt;Importer</name></author>
	</entry>
	<entry>
		<id>https://www.33dai.wiki/index.php?title=06-%E6%95%B0%E5%AD%A6%E7%9B%B8%E5%85%B3/08-%E5%BF%AB%E9%80%9F%E5%B9%82%E4%B8%8E%E5%BF%AB%E9%80%9F%E4%B9%98&amp;diff=275&amp;oldid=prev</id>
		<title>33DAI：​导入1个版本</title>
		<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=06-%E6%95%B0%E5%AD%A6%E7%9B%B8%E5%85%B3/08-%E5%BF%AB%E9%80%9F%E5%B9%82%E4%B8%8E%E5%BF%AB%E9%80%9F%E4%B9%98&amp;diff=275&amp;oldid=prev"/>
		<updated>2026-05-20T16:25:43Z</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;tr class=&quot;diff-title&quot; lang=&quot;zh-Hans-CN&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan=&quot;1&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;2&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;/table&gt;</summary>
		<author><name>33DAI</name></author>
	</entry>
	<entry>
		<id>https://www.33dai.wiki/index.php?title=06-%E6%95%B0%E5%AD%A6%E7%9B%B8%E5%85%B3/08-%E5%BF%AB%E9%80%9F%E5%B9%82%E4%B8%8E%E5%BF%AB%E9%80%9F%E4%B9%98&amp;diff=274&amp;oldid=prev</id>
		<title>-&gt;Importer：​批量导入三三文档</title>
		<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=06-%E6%95%B0%E5%AD%A6%E7%9B%B8%E5%85%B3/08-%E5%BF%AB%E9%80%9F%E5%B9%82%E4%B8%8E%E5%BF%AB%E9%80%9F%E4%B9%98&amp;diff=274&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;
计算 &amp;lt;math&amp;gt;a^b&amp;lt;/math&amp;gt;（模 &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; 意义下），时间复杂度 &amp;lt;math&amp;gt;O(\log b)&amp;lt;/math&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;
int quick_pow(int a, int b, int p)&lt;br /&gt;
{&lt;br /&gt;
    int res = 1;&lt;br /&gt;
    while (b &amp;gt; 0)&lt;br /&gt;
    {&lt;br /&gt;
        if (b &amp;amp; 1)&lt;br /&gt;
            res = 1LL * res * a % p;&lt;br /&gt;
        b &amp;gt;&amp;gt;= 1;&lt;br /&gt;
        a = 1LL * a * a % p;&lt;br /&gt;
    }&lt;br /&gt;
    return res;&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;
int quick_pow(int a, int b, int p)&lt;br /&gt;
{&lt;br /&gt;
    if (b == 0)&lt;br /&gt;
        return 1;&lt;br /&gt;
    int x = quick_pow(a, b / 2, p);&lt;br /&gt;
    if (b % 2 == 0)&lt;br /&gt;
        return 1LL * x * x % p;&lt;br /&gt;
    return 1LL * x * x % p * a % p;&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;math&amp;gt;a\times b&amp;lt;/math&amp;gt;（模 &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; 意义下），防止 &amp;lt;math&amp;gt;a\times b&amp;lt;/math&amp;gt; 爆 &amp;lt;code&amp;gt;long long&amp;lt;/code&amp;gt;。&lt;br /&gt;
&lt;br /&gt;
=== 使用 &amp;lt;code&amp;gt;__int128&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;
long long mul(long long a, long long b, long long p)&lt;br /&gt;
{&lt;br /&gt;
    return (__int128)a * b % p;&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;
long long mul(long long a, long long b, long long p)&lt;br /&gt;
{&lt;br /&gt;
    long long res = 0;&lt;br /&gt;
    while (b)&lt;br /&gt;
    {&lt;br /&gt;
        if (b &amp;amp; 1)&lt;br /&gt;
            res = (res + a) % p;&lt;br /&gt;
        a = (a + a) % p;&lt;br /&gt;
        b &amp;gt;&amp;gt;= 1;&lt;br /&gt;
    }&lt;br /&gt;
    return res;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 使用 &amp;lt;code&amp;gt;long double&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;
long long mul(long long a, long long b, long long p)&lt;br /&gt;
{&lt;br /&gt;
    long long t = (long double)a * b / p;&lt;br /&gt;
    long long res = a * b - t * p;&lt;br /&gt;
    if (res &amp;lt; 0)&lt;br /&gt;
        res += p;&lt;br /&gt;
    if (res &amp;gt;= p)&lt;br /&gt;
        res -= p;&lt;br /&gt;
    return res;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 矩阵快速幂 ==&lt;br /&gt;
&lt;br /&gt;
见 [[05-算法模板/05-矩阵快速幂|矩阵快速幂]]。&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>