<?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=09-%E8%BF%9B%E9%98%B6%E7%AE%97%E6%B3%95%2F03-ST%E8%A1%A8</id>
	<title>09-进阶算法/03-ST表 - 版本历史</title>
	<link rel="self" type="application/atom+xml" href="https://www.33dai.wiki/index.php?action=history&amp;feed=atom&amp;title=09-%E8%BF%9B%E9%98%B6%E7%AE%97%E6%B3%95%2F03-ST%E8%A1%A8"/>
	<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=09-%E8%BF%9B%E9%98%B6%E7%AE%97%E6%B3%95/03-ST%E8%A1%A8&amp;action=history"/>
	<updated>2026-05-20T22:13:18Z</updated>
	<subtitle>本wiki上该页面的版本历史</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://www.33dai.wiki/index.php?title=09-%E8%BF%9B%E9%98%B6%E7%AE%97%E6%B3%95/03-ST%E8%A1%A8&amp;diff=432&amp;oldid=prev</id>
		<title>33DAI：​批量导入三三文档</title>
		<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=09-%E8%BF%9B%E9%98%B6%E7%AE%97%E6%B3%95/03-ST%E8%A1%A8&amp;diff=432&amp;oldid=prev"/>
		<updated>2026-05-20T18:24:01Z</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日 (三) 18:24的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l50&quot;&gt;第50行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第50行：&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:进阶算法]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:进阶算法]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:三三文档]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:三三文档]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key my_wiki:diff:1.41:old-395:rev-432:php=table --&gt;
&lt;/table&gt;</summary>
		<author><name>33DAI</name></author>
	</entry>
	<entry>
		<id>https://www.33dai.wiki/index.php?title=09-%E8%BF%9B%E9%98%B6%E7%AE%97%E6%B3%95/03-ST%E8%A1%A8&amp;diff=395&amp;oldid=prev</id>
		<title>33DAI：​导入1个版本</title>
		<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=09-%E8%BF%9B%E9%98%B6%E7%AE%97%E6%B3%95/03-ST%E8%A1%A8&amp;diff=395&amp;oldid=prev"/>
		<updated>2026-05-20T18:12:16Z</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=09-%E8%BF%9B%E9%98%B6%E7%AE%97%E6%B3%95/03-ST%E8%A1%A8&amp;diff=394&amp;oldid=prev</id>
		<title>-&gt;Importer：​批量导入三三文档</title>
		<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=09-%E8%BF%9B%E9%98%B6%E7%AE%97%E6%B3%95/03-ST%E8%A1%A8&amp;diff=394&amp;oldid=prev"/>
		<updated>2026-05-20T16:50:33Z</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;
== ST表 ==&lt;br /&gt;
&lt;br /&gt;
ST 表（Sparse Table）用于解决&amp;#039;&amp;#039;&amp;#039;可重复贡献问题&amp;#039;&amp;#039;&amp;#039;（如区间最值、区间 GCD），预处理 &amp;lt;math&amp;gt;O(n\log n)&amp;lt;/math&amp;gt;，查询 &amp;lt;math&amp;gt;O(1)&amp;lt;/math&amp;gt;，但不支持修改。&lt;br /&gt;
&lt;br /&gt;
=== 原理 ===&lt;br /&gt;
&lt;br /&gt;
使用倍增思想，&amp;lt;math&amp;gt;st[i][j]&amp;lt;/math&amp;gt; 表示从 &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; 开始长度为 &amp;lt;math&amp;gt;2^j&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;
const int MAXN = 100005;&lt;br /&gt;
const int LOGN = 17; // floor(log2(MAXN))&lt;br /&gt;
int st[MAXN][LOGN + 1];&lt;br /&gt;
&lt;br /&gt;
void build(int n)&lt;br /&gt;
{&lt;br /&gt;
    for (int i = 1; i &amp;lt;= n; i++)&lt;br /&gt;
        st[i][0] = a[i];&lt;br /&gt;
    for (int j = 1; (1 &amp;lt;&amp;lt; j) &amp;lt;= n; j++)&lt;br /&gt;
        for (int i = 1; i + (1 &amp;lt;&amp;lt; j) - 1 &amp;lt;= n; i++)&lt;br /&gt;
            st[i][j] = max(st[i][j - 1], st[i + (1 &amp;lt;&amp;lt; (j - 1))][j - 1]);&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;
// 查询区间 [l, r] 的最大值&lt;br /&gt;
int query(int l, int r)&lt;br /&gt;
{&lt;br /&gt;
    int k = log2(r - l + 1);&lt;br /&gt;
    return max(st[l][k], st[r - (1 &amp;lt;&amp;lt; k) + 1][k]);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 预计算 log2 ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Log2[MAXN];&lt;br /&gt;
void pre_log2(int n)&lt;br /&gt;
{&lt;br /&gt;
    Log2[1] = 0;&lt;br /&gt;
    for (int i = 2; i &amp;lt;= n; i++)&lt;br /&gt;
        Log2[i] = Log2[i / 2] + 1;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:进阶算法]]&lt;br /&gt;
[[Category:三三文档]]&lt;br /&gt;
&lt;/div&gt;</summary>
		<author><name>-&gt;Importer</name></author>
	</entry>
</feed>