<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>皓子的杂站</title>
        <link>https://howiehz.top/misc/</link>
        <description>放不进主站的内容都在这里。</description>
        <lastBuildDate>Wed, 11 Nov 2026 17:44:58 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>zh-Hans</language>
        <copyright>版权所有 © 2023-至今 HowieHz</copyright>
        <atom:link href="https://howiehz.top/misc/rss.zh-hans.xml" rel="self" type="application/rss+xml"/>
        <item>
            <title><![CDATA[HRBUST XCPC 练习 2024 级题解分享]]></title>
            <link>https://howiehz.top/misc/posts/junk/hrbust-2024-solutions</link>
            <guid isPermaLink="false">https://howiehz.top/misc/posts/junk/hrbust-2024-solutions</guid>
            <pubDate>Mon, 02 Sep 2024 14:20:00 GMT</pubDate>
            <description><![CDATA[&lt;!-- markdownlint-disable MD024 --
 HRBUST XCPC 练习 2024 级题解分享
::: details 迁移自主站
- 移动原因：单纯放答案，相较于其]]></description>
            <content:encoded><![CDATA[<!-- markdownlint-disable MD024 -->
<h1 id="hrbust-xcpc-练习-2024-级题解分享" tabindex="-1">HRBUST XCPC 练习 2024 级题解分享 <a class="header-anchor" href="#hrbust-xcpc-练习-2024-级题解分享" aria-label="Permalink to “HRBUST XCPC 练习 2024 级题解分享”">&#8203;</a></h1>
<details class="details custom-block"><summary>迁移自主站</summary>
<ul>
<li>移动原因：单纯放答案，相较于其他认真写的几篇没啥价值。</li>
<li>Hrbust ACM 练习 2024 级第 1~2 周题单 题解分享
<ul>
<li>链接：<code>/archives/hrbustacm-class-of-2024-week-1-2-questionnaire</code></li>
<li>分类：<code>知识传承 &gt; 竞赛解密 &gt; 题解档案</code></li>
<li>标签：<code>简体中文</code> <code>2024</code></li>
<li>发布时间 2024-09-02T22:20:00+08:00</li>
<li>访问量：289</li>
<li>评论量：0</li>
</ul>
</li>
<li>Hrbust ACM 练习 2024 级第 3 周题单 题解分享
<ul>
<li>链接：<code>/archives/hrbustacm-class-of-2024-week-3-questionnaire</code></li>
<li>分类：<code>知识传承 &gt; 竞赛解密 &gt; 题解档案</code></li>
<li>标签：<code>简体中文</code> <code>2024</code></li>
<li>发布时间 2024-09-09T22:50:02+08:00</li>
<li>访问量：229</li>
<li>评论量：1</li>
</ul>
</li>
<li>Hrbust ACM 练习 2024 级第 4 周题单 题解分享 (A-G,J-O)
<ul>
<li>链接：<code>/archives/hrbustacm-class-of-2024-week-4-questionnaire</code></li>
<li>分类：<code>知识传承 &gt; 竞赛解密 &gt; 题解档案</code></li>
<li>标签：<code>简体中文</code> <code>2024</code></li>
<li>发布时间 2024-09-16T20:59:18+08:00</li>
<li>访问量：229</li>
<li>评论量：1</li>
</ul>
</li>
<li>Hrbust ACM 练习 2024 级第 5 周题单 题解分享 (A-C,F-H)
<ul>
<li>链接：<code>/archives/hrbustacm-class-of-2024-week-5-questionnaire</code></li>
<li>分类：<code>知识传承 &gt; 竞赛解密 &gt; 题解档案</code></li>
<li>标签：<code>简体中文</code> <code>2024</code></li>
<li>发布时间 2024-09-24T00:51:42+08:00</li>
<li>访问量：113</li>
<li>评论量：0</li>
</ul>
</li>
<li>Hrbust ACM 编程练习 20240922 题解分享
<ul>
<li>链接：<code>/archives/hrbustacm-programming-exercise-20240922</code></li>
<li>分类：<code>知识传承 &gt; 竞赛解密 &gt; 题解档案</code></li>
<li>标签：<code>简体中文</code> <code>2024</code></li>
<li>发布时间 2024-09-24T13:54:35+08:00</li>
<li>访问量：175</li>
<li>评论量：0</li>
</ul>
</li>
<li>Hrbust ACM 练习 2024 级第 9 周题单 题解分享 (A-B)
<ul>
<li>链接：<code>/archives/hrbustacm-class-of-2024-week-9-questionnaire</code></li>
<li>分类：<code>知识传承 &gt; 竞赛解密 &gt; 题解档案</code></li>
<li>标签：<code>简体中文</code> <code>2024</code></li>
<li>发布时间 2024-11-06T00:51:52+08:00</li>
<li>访问量：89</li>
<li>评论量：0</li>
</ul>
</li>
<li>Hrbust ACM 练习 2024 级第 11 周题单 题解分享 (A-B)
<ul>
<li>链接：<code>/archives/hrbustacm-class-of-2024-week-11-questionnaire</code></li>
<li>分类：<code>知识传承 &gt; 竞赛解密 &gt; 题解档案</code></li>
<li>标签：<code>简体中文</code> <code>2024</code></li>
<li>发布时间 2024-11-10T02:42:13+08:00</li>
<li>访问量：138</li>
<li>评论量：1</li>
</ul>
</li>
</ul>
</details>
<h2 id="hrbust-acm-练习-2024-级第-1-2-周题单-题解分享" tabindex="-1">Hrbust ACM 练习 2024 级第 1~2 周题单 题解分享 <a class="header-anchor" href="#hrbust-acm-练习-2024-级第-1-2-周题单-题解分享" aria-label="Permalink to “Hrbust ACM 练习 2024 级第 1~2 周题单 题解分享”">&#8203;</a></h2>
<h3 id="前言" tabindex="-1">前言 <a class="header-anchor" href="#前言" aria-label="Permalink to “前言”">&#8203;</a></h3>
<p>题单链接：<a href="https://vjudge.net/contest/652737" target="_blank" rel="noreferrer">2024 级第 1~2 周题单 - Virtual Judge (vjudge.net)</a>
熟悉下 oj 的使用。vjudge 感觉没洛谷好用，提交代码的编辑器没语法高亮。
下面的先是 Python3 代码，之后是 C++ 代码。
注意：主要题目数据范围，有些要开 long long。</p>
<h3 id="a-题" tabindex="-1">A 题 <a class="header-anchor" href="#a-题" aria-label="Permalink to “A 题”">&#8203;</a></h3>
<p>Python Code</p>
<div class="language-python" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::my6drgdebokv8e9duw976f::--><code>print(&quot;Hello World!&quot;)</code></pre>
</div><p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::slxfrhb7x5zhc6s7t00cf::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;

int main(){
    cout &lt;&lt; &quot;Hello World!&quot;;
    return 0;
}</code></pre>
</div><h3 id="b-题" tabindex="-1">B 题 <a class="header-anchor" href="#b-题" aria-label="Permalink to “B 题”">&#8203;</a></h3>
<p>Python code</p>
<div class="language-python" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::dimd2d23jtjfzzjbqacwht::--><code>print(chr(int(input())))</code></pre>
</div><p>Cpp code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::gcvcn3pd55ho2e6ngvxmwn::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;

int main()
{
    int ch;
    cin &gt;&gt; ch;
    cout &lt;&lt; static_cast&lt;char&gt;(ch);
    return 0;
}</code></pre>
</div><h3 id="c-题" tabindex="-1">C 题 <a class="header-anchor" href="#c-题" aria-label="Permalink to “C 题”">&#8203;</a></h3>
<p>Python code</p>
<div class="language-python" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::9chku7suvdjmr1e7kds1vj::--><code>print(sum(map(int,input().split())))</code></pre>
</div><p>Cpp code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::tdusm1oyo9znicpbjsezn::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;

int main()
{
    int a, b;
    cin &gt;&gt; a &gt;&gt; b;
    cout &lt;&lt; a+b;
    return 0;
}</code></pre>
</div><h3 id="d-题" tabindex="-1">D 题 <a class="header-anchor" href="#d-题" aria-label="Permalink to “D 题”">&#8203;</a></h3>
<p>Python code</p>
<div class="language-python" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::jpc4drdwcndr5b0wby254n::--><code>print(int(input())**2)</code></pre>
</div><p>Cpp code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::oyh9mvzzv98dbojejf7tv::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;

int main()
{
    long long a;
    cin &gt;&gt; a;
    cout &lt;&lt; a*a;
    return 0;
}</code></pre>
</div><h3 id="e-题" tabindex="-1">E 题 <a class="header-anchor" href="#e-题" aria-label="Permalink to “E 题”">&#8203;</a></h3>
<p>Python code</p>
<div class="language-python" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::02w8blip0nt9h4t3my8xtx::--><code>x=int(input())
print(x**2+2*x+5)</code></pre>
</div><p>Cpp code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::kwnbjdkit6acfy671a6::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;

int main()
{
    int a;
    cin &gt;&gt; a;
    cout &lt;&lt; a*a+a*2+5;
    return 0;
}</code></pre>
</div><h3 id="f-题" tabindex="-1">F 题 <a class="header-anchor" href="#f-题" aria-label="Permalink to “F 题”">&#8203;</a></h3>
<p>Python code</p>
<div class="language-python" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::yv0aqgrb46ahoxkfnvv7xu::--><code>print(f&#039;{(float(input())-32)/9*5:.5f}&#039;)</code></pre>
</div><p>Cpp code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::9ijtd4ob3zm17khjg6c0e5::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;

int main()
{
    double n;
    cin &gt;&gt; n;
    printf(&quot;%.5f\n&quot;, ((n-32)*5/9));
    return 0;
}</code></pre>
</div><h3 id="g-题" tabindex="-1">G 题 <a class="header-anchor" href="#g-题" aria-label="Permalink to “G 题”">&#8203;</a></h3>
<p>9 月 5 日编写</p>
<p>Python code</p>
<div class="language-python" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::uv6k0hyj5qgtkxkucc7qij::--><code>x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
print(f&quot;{((x1-x2)**2+(y1-y2)**2)**0.5:.3f}&quot;)</code></pre>
</div><p>Cpp code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::w4nswrkquuh1uoa91wvy87::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
int main()
{
    int x1, x2, y1, y2;
    cin &gt;&gt; x1 &gt;&gt; y1 &gt;&gt; x2 &gt;&gt; y2;
    cout &lt;&lt; fixed &lt;&lt; setprecision(3) &lt;&lt; sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
    return 0;
}</code></pre>
</div><h3 id="h-题" tabindex="-1">H 题 <a class="header-anchor" href="#h-题" aria-label="Permalink to “H 题”">&#8203;</a></h3>
<p>Python code</p>
<div class="language-python" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::q5nni9cmfgb03koveh18mkw::--><code>x = float(input())
if 0 &lt;= x &lt; 5:
    y = -x + 2.5
elif 5 &lt;= x &lt; 10:
    y = 2 - 1.5 * (x - 3) * (x - 3)
elif 10 &lt;= x &lt; 20:
    y = x / 2 - 1.5
print(f&quot;{y:.3f}&quot;)</code></pre>
</div><p>Cpp code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::tx3qxbyg5et38o6e6e3g::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
int main()
{
    double x, y;
    cin &gt;&gt; x;
    if (0 &lt;= x &amp;&amp; x &lt; 5)
    {
        y = -x + 2.5;
    }
    else if (5 &lt;= x &amp;&amp; x &lt; 10)
    {
        y = 2 - 1.5 * (x - 3) * (x - 3);
    }
    else if (10 &lt;= x &amp;&amp; x &lt; 20)
    {
        y = x / 2 - 1.5;
    }
    cout &lt;&lt; fixed &lt;&lt; setprecision(3) &lt;&lt; y;
    return 0;
}</code></pre>
</div><h3 id="i-题" tabindex="-1">I 题 <a class="header-anchor" href="#i-题" aria-label="Permalink to “I 题”">&#8203;</a></h3>
<p>Python code</p>
<div class="language-python" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::wdmlgzghrtmxgl7uop39m::--><code>n = int(input())
def a():
    for i in range(2, n):
        if n % i == 0:
            print(&quot;No&quot;)
            return
    print(&quot;Yes&quot;)
a()</code></pre>
</div><p>Cpp code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::vr74f5xz5yc96xaaoraz1v::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
int main()
{
    int n;
    cin &gt;&gt; n;
    for (int i = 2; i &lt;= n - 1; i++)
    {
        if (n % i == 0)
        {
            cout &lt;&lt; &quot;No&quot;;
            return 0;
        }
    }
    cout &lt;&lt; &quot;Yes&quot;;
    return 0;
}</code></pre>
</div><h3 id="j-题" tabindex="-1">J 题 <a class="header-anchor" href="#j-题" aria-label="Permalink to “J 题”">&#8203;</a></h3>
<p>Python code</p>
<div class="language-python" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::g9rw093drmigqlp3jcqbak::--><code>w = int(input())
if w &gt; 2 and w % 2 == 0:
    print(&quot;YES&quot;)
else:
    print(&quot;NO&quot;)</code></pre>
</div><p>Cpp code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::9r1ds7sin68tlobxrxj2p::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
int main()
{
    int w;
    cin &gt;&gt; w;
    if (w &gt; 2 &amp;&amp; w % 2 == 0)
    {
        cout &lt;&lt; &quot;YES&quot;;
    }
    else
    {
        cout &lt;&lt; &quot;NO&quot;;
    }
    return 0;
}</code></pre>
</div><h3 id="k-题" tabindex="-1">K 题 <a class="header-anchor" href="#k-题" aria-label="Permalink to “K 题”">&#8203;</a></h3>
<p>Python code</p>
<div class="language-python" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::6p2ei1f1j7q7alm226b7s9::--><code>n = int(input())
rt = 0
while n &gt; 0:
    n -= 1
    if sum(map(int, input().split())) &gt;= 2:
        rt += 1
print(rt)</code></pre>
</div><p>Cpp code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::ut5y3se6tupc0zcgwhl6b::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
int main()
{
    int lines, ret;
    ret = 0;
    cin &gt;&gt; lines;
    while (lines &gt; 0)
    {
        lines--;
        int x, y, z;
        cin &gt;&gt; x &gt;&gt; y &gt;&gt; z;
        if (x + y + z &gt;= 2)
        {
            ret++;
        }
    }
    cout &lt;&lt; ret;
    return 0;
}</code></pre>
</div><h3 id="l-题" tabindex="-1">L 题 <a class="header-anchor" href="#l-题" aria-label="Permalink to “L 题”">&#8203;</a></h3>
<p>Python code</p>
<div class="language-python" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::edupuut08ve6kx8tqmippa::--><code>n = int(input())
while n &gt; 0:
    n -= 1
    word = input()
    if len(word) &gt; 10:
        print(word[0] + str(len(word) - 2) + word[-1])
    else:
        print(word)</code></pre>
</div><p>Cpp code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::9t0iwpevb5nyl08lhbpop::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
int main()
{
    int n;
    cin &gt;&gt; n;
    while (n &gt; 0)
    {
        n--;
        string s;
        cin &gt;&gt; s;
        if (s.size() &gt; 10)
        {
            cout &lt;&lt; s.substr(0, 1) &lt;&lt; s.size() - 2 &lt;&lt; s.substr(s.size() - 1, s.size()) &lt;&lt; endl;
        }
        else
        {
            cout &lt;&lt; s &lt;&lt; endl;
        }
    }
    return 0;
}</code></pre>
</div><h2 id="hrbust-acm-练习-2024-级第-3-周题单-题解分享" tabindex="-1">Hrbust ACM 练习 2024 级第 3 周题单 题解分享 <a class="header-anchor" href="#hrbust-acm-练习-2024-级第-3-周题单-题解分享" aria-label="Permalink to “Hrbust ACM 练习 2024 级第 3 周题单 题解分享”">&#8203;</a></h2>
<h3 id="前言-1" tabindex="-1">前言 <a class="header-anchor" href="#前言-1" aria-label="Permalink to “前言”">&#8203;</a></h3>
<p>题单链接：<a href="https://vjudge.net/contest/654371" target="_blank" rel="noreferrer">2024 级第 3 周题单 - Virtual Judge (vjudge.net)</a>
有些题不能提交 Python 代码，所以只有 Cpp 代码。</p>
<p>我尝试找了找这些题的出处，搜索引擎中搜到的题解大多比笔者写得更好，所以建议直接检索对应题目的题解。</p>
<ul>
<li>A 题是 SWUSTOJ 1178</li>
<li>B 题是 零起点学算法 106</li>
<li>C 题是 水仙花数，很多 oj 都有，比较常见。但是这个变体没搜到，可能是原创题。</li>
<li>D 题是 HDU 2016</li>
<li>E 题是 HDU 2017</li>
<li>F 题是 HDU 2043</li>
<li>G 题是 HDU 1062</li>
<li>H 题是 HDU 2020</li>
<li>I 题是 51Nod 3212</li>
<li>J 题是 <a href="https://vjudge.net/problem/%E8%AE%A1%E8%92%9C%E5%AE%A2-T1715/origin" target="_blank" rel="noreferrer">计蒜客-T1715</a></li>
<li>K 题是 <a href="https://vjudge.net/problem/%E8%AE%A1%E8%92%9C%E5%AE%A2-T1232/origin" target="_blank" rel="noreferrer">计蒜客-T1232</a></li>
</ul>
<h3 id="a-题-1" tabindex="-1">A 题 <a class="header-anchor" href="#a-题-1" aria-label="Permalink to “A 题”">&#8203;</a></h3>
<p>Python Code</p>
<div class="language-python" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::4ox202tu7mrzkeimakg1h::--><code>s = input()
for c in s:
    if &quot;a&quot; &lt;= c &lt;= &quot;y&quot; or &quot;A&quot; &lt;= c &lt;= &quot;Y&quot;:
        print(chr(ord(c) + 1), end=&quot;&quot;)
    elif c == &quot;z&quot;:
        print(&quot;a&quot;, end=&quot;&quot;)
    elif c == &quot;Z&quot;:
        print(&quot;A&quot;, end=&quot;&quot;)
    else:
        print(c, end=&quot;&quot;)</code></pre>
</div><p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::bgl3x0p1flgz00ywl09qek::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
int main()
{
    string s;
    getline(cin, s);
    for (char c : s)
    {
        if (&#039;a&#039; &lt;= c &amp;&amp; c &lt;= &#039;y&#039;)
        {
            cout &lt;&lt; char(c + 1);
        }
        else if (&#039;A&#039; &lt;= c &amp;&amp; c &lt;= &#039;Y&#039;)
        {
            cout &lt;&lt; char(c + 1);
        }
        else if (c == &#039;z&#039;)
        {
            cout &lt;&lt; &#039;a&#039;;
        }
        else if (c == &#039;Z&#039;)
        {
            cout &lt;&lt; &#039;A&#039;;
        }
        else
        {
            cout &lt;&lt; c;
        }
    }
    cout &lt;&lt; &quot; &quot;;
    return 0;
}</code></pre>
</div><h3 id="b-题-1" tabindex="-1">B 题 <a class="header-anchor" href="#b-题-1" aria-label="Permalink to “B 题”">&#8203;</a></h3>
<p>Python Code</p>
<div class="language-python" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::7o2ksxkesj6j7qulhj9lr::--><code>s = input().split()
rt_s = []
for i in s:
    rt_s.append(i.capitalize())
print(&quot; &quot;.join(rt_s))</code></pre>
</div><p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::tcwvf3vsnebxu9jqqp140b::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
int main()
{
    string word;
    while (cin &gt;&gt; word)
    {
        word[0] = toupper(word[0]);
        cout &lt;&lt; word &lt;&lt; &quot; &quot;;
    }
}</code></pre>
</div><h3 id="c-题-1" tabindex="-1">C 题 <a class="header-anchor" href="#c-题-1" aria-label="Permalink to “C 题”">&#8203;</a></h3>
<p>这题 水仙花数 很常见，很多 oj 都有类似的</p>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::uqydlewctyru97orlfzth::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
int main()
{
    int a, b, yesorno;
    while (cin &gt;&gt; a &gt;&gt; b)
    {
        yesorno = 0;
        for (int i = a; i &lt;= b; i++)
        {
            if (pow((i / 100), 3) + pow((i / 10 % 10), 3) + pow((i % 10), 3) == i)
            {
                cout &lt;&lt; i &lt;&lt; &quot; &quot;;
                yesorno = 1;
            }
        }
        if (yesorno == 0)
        {
            cout &lt;&lt; &quot;no&quot; &lt;&lt; endl;
        } else{
            cout &lt;&lt; endl;
        }
    }
}</code></pre>
</div><h3 id="d-题-1" tabindex="-1">D 题 <a class="header-anchor" href="#d-题-1" aria-label="Permalink to “D 题”">&#8203;</a></h3>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::zjexygz8hx875xmtwuaav::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
int main()
{
    int n, b;
    while (cin &gt;&gt; n)
    {
        if (n == 0)
        {
            return 0;
        }

        list&lt;int&gt; int_list;
        while (n &gt; 0)
        {
            n--;
            cin &gt;&gt; b;
            int_list.push_back(b);
        }

        list&lt;int&gt; new_int_list = int_list;
        new_int_list.sort();
        int min_number = new_int_list.front();

        list&lt;int&gt;::iterator it = find(int_list.begin(), int_list.end(), min_number);

        int index;
        if (it != int_list.end())
        {
            index = distance(int_list.begin(), it);
        }

        auto it2 = next(int_list.begin(), index);

        *it2 = *int_list.begin();
        *int_list.begin() = min_number;

        while (int_list.size() != 0)
        {
            cout &lt;&lt; int_list.front() &lt;&lt; &quot; &quot;;
            int_list.pop_front();
        }
        cout &lt;&lt; endl;
    }
}</code></pre>
</div><h3 id="e-题-1" tabindex="-1">E 题 <a class="header-anchor" href="#e-题-1" aria-label="Permalink to “E 题”">&#8203;</a></h3>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::5tyjpoemvzchtwt0dge09::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
int main()
{
    int n;
    cin &gt;&gt; n;
    while (n &gt; 0)
    {
        n--;
        string s;
        int ret = 0;
        cin &gt;&gt; s;
        for (char c : s)
        {
            if (isdigit(c))
            {
                ret++;
            }
        }
        cout &lt;&lt; ret;
    }
}</code></pre>
</div><h3 id="f-题-1" tabindex="-1">F 题 <a class="header-anchor" href="#f-题-1" aria-label="Permalink to “F 题”">&#8203;</a></h3>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::xfjdiz96pnj60ia80mxwrl::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;

bool check(string s)
{
    bool upper = false, lower = false, digit = false, special = false;

    for (char c : s)
    {
        if (isupper(c))
        {
            upper = true;
            continue;
        }
        else if (islower(c))
        {
            lower = true;
            continue;
        }
        else if (isdigit(c))
        {
            digit = true;
            continue;
        }
        else if (c == &#039;~&#039; or c == &#039;!&#039; or c == &#039;@&#039; or c == &#039;#&#039; or c == &#039;$&#039; or c == &#039;%&#039; or c == &#039;^&#039;)
        {
            special = true;
            continue;
        }
    }

    if (upper + lower + digit + special &gt;= 3)
    {
        return true;
    }
    else
    {
        return false;
    }
}

int main()
{
    int n;
    cin &gt;&gt; n;
    while (n &gt; 0)
    {
        n--;
        string s;
        cin &gt;&gt; s;
        if (s.size() &lt; 8 or s.size() &gt; 16)
        {
            cout &lt;&lt; &quot;NO&quot; &lt;&lt; endl;
            continue;
        }

        if (check(s))
        {
            cout &lt;&lt; &quot;YES&quot; &lt;&lt; endl;
            continue;
        }
        else
        {
            cout &lt;&lt; &quot;NO&quot; &lt;&lt; endl;
            continue;
        }
    }
    return 0;
}</code></pre>
</div><h3 id="g-题-1" tabindex="-1">G 题 <a class="header-anchor" href="#g-题-1" aria-label="Permalink to “G 题”">&#8203;</a></h3>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::7oyyviiwrtdeduvu619mzn::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
int main()
{
    int n;
    cin &gt;&gt; n;
    cin.get();
    while (n &gt; 0)
    {
        n--;
        string str;
        list&lt;char&gt; char_list;
        list&lt;char&gt; char_list_r;
        getline(cin, str);
        for (char c : str)
        {
            if (c == &#039; &#039;)
            {
                for (auto const &amp;i : char_list_r)
                {
                    cout &lt;&lt; i;
                }
                char_list_r.clear();
                cout &lt;&lt; &#039; &#039;;
                continue;
            }
            char_list_r.push_front(c);
        }
        for (auto const &amp;i : char_list_r)
        {
            cout &lt;&lt; i;
        }
        char_list_r.clear();
        cout &lt;&lt; endl;
    }
}</code></pre>
</div><h3 id="h-题-1" tabindex="-1">H 题 <a class="header-anchor" href="#h-题-1" aria-label="Permalink to “H 题”">&#8203;</a></h3>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::octgrp67od90i7x6gi9vlsk::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;

bool cmp(const int a, const int b)
{
    return abs(a) &gt; abs(b);
}

int main()
{
    int n, b;
    while (cin &gt;&gt; n)
    {
        if (n == 0)
        {
            return 0;
        }
        list&lt;int&gt; int_list;
        while (n &gt; 0)
        {
            n--;
            cin &gt;&gt; b;
            int_list.push_back(b);
        }
        int_list.sort(cmp);
        for (auto const &amp;i : int_list)
        {
            cout &lt;&lt; i &lt;&lt; &quot; &quot;;
        }
        cout &lt;&lt; endl;
    }
}</code></pre>
</div><h3 id="i-题-1" tabindex="-1">I 题 <a class="header-anchor" href="#i-题-1" aria-label="Permalink to “I 题”">&#8203;</a></h3>
<p>Python Code</p>
<div class="language-python" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::6rzhb2quauewm2q8em94w::--><code>n = int(input())
l = []
while True:
    if n == 0:
        break
    l.append(str(n % 10))
    n //= 10
min_n = sorted(l)
if min_n[0] == &quot;0&quot;:
    for index, n in enumerate(min_n):
        if n != &quot;0&quot;:
            min_n[0] = min_n[index]
            min_n[index] = &quot;0&quot;
            break
print(&quot;&quot;.join(sorted(l, reverse=True)), &quot;&quot;.join(min_n))</code></pre>
</div><p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::udh7zr8ez7cqyb56j8nyo::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;

int main() {
    long long n;
    cin &gt;&gt; n;
    list&lt;long long&gt; int_list;
    list&lt;long long&gt; int_list_r;
    while (true) {
        if (n == 0) {
            break;
        }
        int_list.push_back(n % 10);
        n /= 10;
    }
    int_list.sort();

    for (long long n : int_list) {
        int_list_r.push_front(n);
    }

    for (auto const &amp;i : int_list_r) {
        cout &lt;&lt; i;
    }
    cout &lt;&lt; &quot; &quot;;

    while (int_list.front() == 0) {
        auto it = int_list.begin();
        while (*(it++) == 0) {
            continue;
        }
        int_list.emplace(it, 0);
        int_list.pop_front();
    }
    for (auto const &amp;i : int_list) {
        cout &lt;&lt; i;
    }
}</code></pre>
</div><h3 id="j-题-1" tabindex="-1">J 题 <a class="header-anchor" href="#j-题-1" aria-label="Permalink to “J 题”">&#8203;</a></h3>
<p>这题奇怪的是<code>思路一实现一</code>只需要开 99 大小的数组就能过，而<code>思路二实现二</code>需要开 100 大小的数组才能过。</p>
<p>思路一实现一 Cpp Code（关键：用 scanf 写入 char[] 无需取址、用 strcpy 写入结构体 char[])</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::yjqdp1ikpummip7kox2k::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
struct T
{
    char name[21];
    long long order;
} tl[99];

bool cmp(T a, T b)
{
    return a.order &lt; b.order;
}

int main()
{
    int n;
    cin &gt;&gt; n;

    for (int i = 0; i &lt; n; i++)
    {
        char name[21];
        long long y, m, d, input_order;
        scanf(&quot;%s %lld %lld %lld&quot;, name, &amp;y, &amp;m, &amp;d);

        input_order = n - i;

        strcpy(tl[i].name, name);
        tl[i].order = y * 10000000 + m * 100000 + d * 1000 + input_order;
    }

    sort(tl, tl + n, cmp);

    for (int i = 0; i &lt; n; i++)
    {
        cout &lt;&lt; tl[i].name &lt;&lt; endl;
    }

    return 0;
}</code></pre>
</div><p>思路一实现二 Cpp Code 另一种实现（关键：结构体用 string、scanf 写入 string 的方法）</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::kw0nm6ozlpaqqeo81zykbs::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
struct T {
    string name;
    long long order;
} tl[100];

bool cmp(T a, T b) { return a.order &lt; b.order; }

int main() {
    int n;
    cin &gt;&gt; n;

    for (int i = 0; i &lt; n; i++) {
        string name;
        name.resize(21);
        long long y, m, d, input_order;
        scanf(&quot;%s %lld %lld %lld&quot;, &amp;name[0], &amp;y, &amp;m, &amp;d);

        input_order = n - i;

        // 调用 c_str 方法，清除上面 resize 方法多申请的空间
        name = name.c_str();

        // 另一种方法清除上面 resize 方法多申请的空间，由李晟霄同学提供
        // for (int i = 0; i &lt; name.length(); i++) {
        //     if (int(name[i]) == 0) {
        //         name.resize(i);
        //         break;
        //     }
        // }

        tl[i].name = name;
        tl[i].order = y * 10000000 + m * 100000 + d * 1000 + input_order;
    }

    sort(tl, tl + n, cmp);

    for (int i = 0; i &lt; n; i++) {
        cout &lt;&lt; tl[i].name &lt;&lt; endl;
    }

    return 0;
}</code></pre>
</div><p>思路二实现一 Cpp Code 另一种实现（关键：cin 直接写入结构体 string）</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::vb3kr83jen8en7ltiwup3::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
struct T
{
    long long y, m, d, order;
    string name;
} tl[100];

bool cmp(T n1, T n2)
{
    if (n1.y != n2.y)
    {
        return n1.y &lt; n2.y;
    }
    if (n1.m != n2.m)
    {
        return n1.m &lt; n2.m;
    }
    if (n1.d != n2.d)
    {
        return n1.d &lt; n2.d;
    }
    return n1.order &gt; n2.order;
}

int main()
{
    int n;
    cin &gt;&gt; n;
    for (int i = 0; i &lt; n; i++)
    {
        cin &gt;&gt; tl[i].name &gt;&gt; tl[i].y &gt;&gt; tl[i].m &gt;&gt; tl[i].d;
        tl[i].order = i;
    }

    sort(tl, tl + n, cmp);

    for (int i = 0; i &lt; n; i++)
    {
        cout &lt;&lt; tl[i].name &lt;&lt; endl;
    }

    return 0;
}</code></pre>
</div><h3 id="k-题-1" tabindex="-1">K 题 <a class="header-anchor" href="#k-题-1" aria-label="Permalink to “K 题”">&#8203;</a></h3>
<p>Python Code</p>
<div class="language-python" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::j7z2pg6o45szqmxkn640yh::--><code>t = input()
n = int(input())
l = [input() for _ in range(n)]

if t == &quot;inc&quot;:
    l.sort()
elif t == &quot;dec&quot;:
    l.sort(reverse=True)
elif t == &quot;ncinc&quot;:
    l.sort(key=lambda s: s.lower())
else:
    l.sort(key=lambda s: s.lower(), reverse=True)

for s in l:
    print(s)</code></pre>
</div><p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::fbnqzdcmk7mhkfu9l67b2i::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;

string tolower_string(const string &amp;s)
{
    string lower_s = s;
    transform(lower_s.begin(), lower_s.end(), lower_s.begin(), ::tolower);
    return lower_s;
}

bool cicmp(const string &amp;m, const string &amp;n) // case insensitive compare
{
    return tolower_string(m) &lt; tolower_string(n);
}

bool cicmpr(const string &amp;m, const string &amp;n)
{
    return tolower_string(m) &gt; tolower_string(n);
}

int main()
{
    string t;
    int n;

    cin &gt;&gt; t;
    cin &gt;&gt; n;

    vector&lt;string&gt; l(n);
    for (int i = 0; i &lt; n; ++i)
    {
        cin &gt;&gt; l[i];
    }

    if (t == &quot;inc&quot;)
    {
        sort(l.begin(), l.end());
        // sort(l.begin(), l.end(), less&lt;string&gt;());
    }
    else if (t == &quot;dec&quot;)
    {
        sort(l.begin(), l.end(), greater&lt;string&gt;());
    }
    else if (t == &quot;ncinc&quot;)
    {
        sort(l.begin(), l.end(), cicmp);
    }
    else
    {
        sort(l.begin(), l.end(), cicmpr);
    }

    for (const string &amp;s : l)
    {
        cout &lt;&lt; s &lt;&lt; endl;
    }

    return 0;
}</code></pre>
</div><h2 id="hrbust-acm-练习-2024-级第-4-周题单-题解分享-a-g-j-o" tabindex="-1">Hrbust ACM 练习 2024 级第 4 周题单 题解分享 (A-G,J-O) <a class="header-anchor" href="#hrbust-acm-练习-2024-级第-4-周题单-题解分享-a-g-j-o" aria-label="Permalink to “Hrbust ACM 练习 2024 级第 4 周题单 题解分享 (A-G,J-O)”">&#8203;</a></h2>
<h3 id="前言-2" tabindex="-1">前言 <a class="header-anchor" href="#前言-2" aria-label="Permalink to “前言”">&#8203;</a></h3>
<p>题单链接：<a href="https://vjudge.net/contest/655873" target="_blank" rel="noreferrer">2024 级第 4 周题单 - Virtual Judge (vjudge.net)</a></p>
<p>很多同学困惑怎么学习 C++，我在此分享下我的经验。
我也是刚学习 C++ 没几天，按照我之前自己学习 Python 的经验来说，如果有条件买本<strong>翻译水平较好的外国著作</strong>来学习是再好不过的，退一步来说就是从网上的文章或者从下载的电子书中学习 C++。</p>
<p>在我的个人体验中，通过高效精练的文字中学习是比从视频和直播中学习更快的。一本好的书更是能作为参考书来随时查阅。</p>
<p>网站我推荐 <a href="https://oi.wiki/" target="_blank" rel="noreferrer">OI Wiki</a>，在这个网站你可以学习到竞赛所需的语言知识和算法知识，另外推荐使用<a href="https://www.luogu.com.cn/" target="_blank" rel="noreferrer">洛谷 OJ</a> 中的官方题单进行能力训练。</p>
<p>祝大家学有所成！</p>
<h3 id="a-题-2" tabindex="-1">A 题 <a class="header-anchor" href="#a-题-2" aria-label="Permalink to “A 题”">&#8203;</a></h3>
<p>直接累加会超时，打表观察后直接计算。</p>
<p>Python Code</p>
<div class="language-python" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::ccee4vr1dngwmkl3ekkn9p::--><code>from math import ceil

n = int(input())
if n % 2 == 0:
    print(ceil(n / 2))
else:
    print(-ceil(n / 2))</code></pre>
</div><p>Python Code 另一种实现</p>
<div class="language-python" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::9az7kzdgojftshddov6xpd::--><code>n = int(input())
s = (n + 1) // 2
if n % 2 == 0:
    print(s)
else:
    print(-s)</code></pre>
</div><p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::nmp8iqtv56qvu3cbff8w::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    ll n;
    cin &gt;&gt; n;
    ll s = (n + 1) / 2;
    if (n % 2 == 1) {
        cout &lt;&lt; -s;
    } else {
        cout &lt;&lt; s;
    }
    return 0;
}</code></pre>
</div><h3 id="b-题-2" tabindex="-1">B 题 <a class="header-anchor" href="#b-题-2" aria-label="Permalink to “B 题”">&#8203;</a></h3>
<p>直接用标准库实现即可</p>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::igbakgbu0rkbexl5wplstc::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin &gt;&gt; n;
    vector&lt;int&gt; l;

    while (n &gt; 0) {
        n--;
        int a;
        cin &gt;&gt; a;

        if (a == 1) {
            int t;
            cin &gt;&gt; t;
            l.push_back(t);
        } else if (a == 2) {
            sort(l.begin(), l.end());
        } else if (a == 3) {
            reverse(l.begin(), l.end());
        } else if (a == 4) {
            cout &lt;&lt; l.size() &lt;&lt; endl;
        } else if (a == 5) {
            for (int i : l) {
                cout &lt;&lt; i &lt;&lt; &quot; &quot;;
            }
            cout &lt;&lt; endl;
        } else if (a == 6) {
            l.clear();
        }
    }
    return 0;
}</code></pre>
</div><h3 id="c-题-2" tabindex="-1">C 题 <a class="header-anchor" href="#c-题-2" aria-label="Permalink to “C 题”">&#8203;</a></h3>
<p>直接用标准库实现即可</p>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::yxyelux0c0e2ioz1s6i0g6::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin &gt;&gt; n;
    stack&lt;int&gt; l;
    while (n &gt; 0) {
        n--;
        int a;
        cin &gt;&gt; a;

        if (a == 1) {
            int t;
            cin &gt;&gt; t;
            l.push(t);
        } else if (a == 2) {
            cout &lt;&lt; l.top() &lt;&lt; endl;
        } else if (a == 3) {
            l.pop();
        } else if (a == 4) {
            cout &lt;&lt; l.size() &lt;&lt; endl;
        }
    }
}</code></pre>
</div><h3 id="d-题-2" tabindex="-1">D 题 <a class="header-anchor" href="#d-题-2" aria-label="Permalink to “D 题”">&#8203;</a></h3>
<p>直接用标准库实现即可</p>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::hcmupstwdwsl2rh2svamda::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin &gt;&gt; n;
    stack&lt;int&gt; l;
    while (n &gt; 0) {
        n--;
        int a;
        cin &gt;&gt; a;

        if (a == 1) {
            int t;
            cin &gt;&gt; t;
            l.push(t);
        } else if (a == 2) {
            cout &lt;&lt; l.top() &lt;&lt; endl;
        } else if (a == 3) {
            l.pop();
        } else if (a == 4) {
            cout &lt;&lt; l.size() &lt;&lt; endl;
        }
    }
}</code></pre>
</div><h3 id="e-题-2" tabindex="-1">E 题 <a class="header-anchor" href="#e-题-2" aria-label="Permalink to “E 题”">&#8203;</a></h3>
<p>按照要求操作即可</p>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::fo08jowleb4gg3r81i17y8::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    int T, m, i = 0;
    long long unsigned n;
    cin &gt;&gt; T;

    while (T &gt; 0) {
        T--;
        i++;
        cout &lt;&lt; &quot;Case &quot; &lt;&lt; i &lt;&lt; &quot;:&quot; &lt;&lt; endl;
        cin &gt;&gt; n &gt;&gt; m;
        deque&lt;int&gt; l;
        while (m &gt; 0) {
            m--;
            string a;
            cin &gt;&gt; a;

            if (a == &quot;pushLeft&quot;) {
                int number;
                cin &gt;&gt; number;
                if (l.size() == n) {
                    cout &lt;&lt; &quot;The queue is full&quot; &lt;&lt; endl;
                } else {
                    l.push_front(number);
                    cout &lt;&lt; &quot;Pushed in left: &quot; &lt;&lt; number &lt;&lt; endl;
                }
            } else if (a == &quot;pushRight&quot;) {
                int number;
                cin &gt;&gt; number;
                if (l.size() == n) {
                    cout &lt;&lt; &quot;The queue is full&quot; &lt;&lt; endl;
                } else {
                    l.push_back(number);
                    cout &lt;&lt; &quot;Pushed in right: &quot; &lt;&lt; number &lt;&lt; endl;
                }
            } else if (a == &quot;popLeft&quot;) {
                if (l.size() == 0) {
                    cout &lt;&lt; &quot;The queue is empty&quot; &lt;&lt; endl;
                } else {
                    cout &lt;&lt; &quot;Popped from left: &quot; &lt;&lt; l.front() &lt;&lt; endl;
                    l.pop_front();
                }
            } else if (a == &quot;popRight&quot;) {
                if (l.size() == 0) {
                    cout &lt;&lt; &quot;The queue is empty&quot; &lt;&lt; endl;
                } else {
                    cout &lt;&lt; &quot;Popped from right: &quot; &lt;&lt; l.back() &lt;&lt; endl;
                    l.pop_back();
                }
            }
        }
    }
    return 0;
}</code></pre>
</div><h3 id="f-题-2" tabindex="-1">F 题 <a class="header-anchor" href="#f-题-2" aria-label="Permalink to “F 题”">&#8203;</a></h3>
<p>原题链接：<a href="https://acm.hdu.edu.cn/showproblem.php?pid=1022" target="_blank" rel="noreferrer">HDU 1022</a></p>
<p>车库是个 stack 命名为 st
火车进入序列（顺序）是 st_in
火车退出序列（顺序）是 st_out</p>
<p>思路很简单，每次循环只要车库有车，就先比较<code>车库最口上的车和 st_out 下一个要求出去的车</code>是不是一样的，如果是一样的就出车（st 出车，st_out 删掉要求出车）。
如果<code>车库没车</code>或者<code>车库有车但是车库最口上的车和 st_out 下一个要求出去的车不一样</code>，就从 st_in 取一辆车。
如果从 st_in 取车的时候发现无车可取（st_in 的 size 为 0），那就退出循环。</p>
<p>退出循环后只有两种可能</p>
<ol>
<li>车库没车，从 st_in 取车也没车。这个时候退出的循环，其实就是车全部按照序列走光了。那就是成功了。这时候 st_out 的 size 一定是 0，st 的 size 也是 0。</li>
<li>车库有车，但是<code>车库有车但是车库最口上的车和 st_out 下一个要求出去的车不一样</code>，从 st_in 取车没车。这个时候退出循环说明车被堵住了，没法按照退出序列把车开出去，那就是失败了。这时候 st_out 的 size 一定不为 0，st 的 size 也不为 0。</li>
</ol>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::y9ktyylu0qfvbo69vln00g::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    int n_o;
    while (cin &gt;&gt; n_o) {
        deque&lt;int&gt; st_in;
        deque&lt;int&gt; st_out;
        stack&lt;int&gt; st;
        deque&lt;string&gt; operations;
        int n = n_o;

        getchar();  // read space
        while (n &gt; 0) {
            st_in.push_back(getchar());
            n--;
        }

        getchar();  // read space
        n = n_o;
        while (n &gt; 0) {
            st_out.push_back(getchar());
            n--;
        }

        while (true) {
            if (st.size() != 0 &amp;&amp; st.top() == st_out.front()) {
                st.pop();
                st_out.pop_front();
                operations.push_back(&quot;out&quot;);
            } else {
                if (st_in.size() == 0) {
                    break;
                } else {
                    st.push(st_in.front());
                    st_in.pop_front();
                    operations.push_back(&quot;in&quot;);
                }
            }
        }

        if (st.size() == 0) {
            cout &lt;&lt; &quot;Yes.&quot; &lt;&lt; endl;
            for (string s : operations) {
                cout &lt;&lt; s &lt;&lt; endl;
            }
        } else {
            cout &lt;&lt; &quot;No.&quot; &lt;&lt; endl;
        }
        cout &lt;&lt; &quot;FINISH&quot; &lt;&lt; endl;
    }
    return 0;
}</code></pre>
</div><h3 id="g-题-2" tabindex="-1">G 题 <a class="header-anchor" href="#g-题-2" aria-label="Permalink to “G 题”">&#8203;</a></h3>
<p>原题链接：<a href="https://onlinejudge.org/index.php?option=com_onlinejudge&amp;Itemid=8&amp;category=8&amp;page=show_problem&amp;problem=614" target="_blank" rel="noreferrer">UVA 673</a></p>
<p>这题要注意：需要检查的字符串可能为空</p>
<p>Python Code</p>
<div class="language-python" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::k1yrl6oji57iod9wn8fras::--><code>def a(s):
    st = []
    d = {&quot;(&quot;: &quot;)&quot;, &quot;[&quot;: &quot;]&quot;}

    for c in s:
        if c in &quot;)]&quot;:
            if st and d[st[-1]] == c:
                st.pop()
            else:
                return &quot;No&quot;
        else:
            st.append(c)

    return &quot;No&quot; if st else &quot;Yes&quot;


[print(a(input().strip())) for _ in range(int(input()))]</code></pre>
</div><p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::6sk92d5mwjd8qxzxumhpvr::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

string a(string s) {
    stack&lt;char&gt; l;
    map&lt;char, char&gt; d = {{&#039;(&#039;, &#039;)&#039;}, {&#039;[&#039;, &#039;]&#039;}};

    for (char c : s) {
        if (c == &#039;)&#039; || c == &#039;]&#039;) {
            if (!l.empty() &amp;&amp; d[l.top()] == c) {
                l.pop();
            } else {
                return &quot;No&quot;;
            }
        } else {
            l.push(c);
        }
    }
    if (l.empty()) {
        return &quot;Yes&quot;;
    } else {
        return &quot;No&quot;;
    }
}

int main() {
    int n;
    cin &gt;&gt; n;
    getchar();  // 读取上一行输入数据后输入的回车
    while (n &gt; 0) {
        string s;
        getline(cin, s);  // 用 getline 而不是用 cin 是因为后面的字符串序列可能为空
        cout &lt;&lt; a(s) &lt;&lt; endl;
        n--;
    }
    return 0;
}</code></pre>
</div><h3 id="h-题-2" tabindex="-1">H 题 <a class="header-anchor" href="#h-题-2" aria-label="Permalink to “H 题”">&#8203;</a></h3>
<p>24.9.22 更新</p>
<p>原题是 The 2024 ICPC Asia East Continent Online Contest (I) 的 F 题</p>
<blockquote>
<p>此题未通过</p>
</blockquote>
<p>这题对于我来说太难，一直超时，跳过</p>
<div class="language-python" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::9sz07esoo9er6fvk5xxy7::--><code>c = int(input())

while c &gt; 0:
    rt = 0
    c -= 1
    n = int(input())
    index_max = n - 1
    l = list(map(int, input().split()))
    for i, e in enumerate(l):
        l_step = 0
        r_step = 0
        l_max_number = e
        r_max_number = e
        for l_number in l[i::-1]:
            if l_number &gt; l_max_number:
                l_max_number = l_number
                l_step += 1
            if l_number &lt; l_max_number:
                break
        for r_number in l[i + 1 :]:
            if r_number &gt; r_max_number:
                r_max_number = r_number
                r_step += 1
            if r_number &lt; r_max_number:
                break
        rt += l_step + r_step
    print(rt)</code></pre>
</div><h3 id="i-题-2" tabindex="-1">I 题 <a class="header-anchor" href="#i-题-2" aria-label="Permalink to “I 题”">&#8203;</a></h3>
<p>原题链接：<a href="https://codeforces.com/contest/2013/problem/D" target="_blank" rel="noreferrer">Codeforces 2013D</a></p>
<h3 id="j-题-2" tabindex="-1">J 题 <a class="header-anchor" href="#j-题-2" aria-label="Permalink to “J 题”">&#8203;</a></h3>
<p>24.9.22 凌晨更新题解</p>
<p>原题链接：<a href="https://acm.hdu.edu.cn/showproblem.php?pid=2034" target="_blank" rel="noreferrer">HDU 2034</a></p>
<p>没啥难度，题目的 A-B 是 <mjx-container v-pre class="MathJax" jax="SVG" style="direction: ltr; position: relative;"><svg style="overflow: visible; min-height: 1px; min-width: 1px; vertical-align: -0.375ex;" xmlns="http://www.w3.org/2000/svg" width="8.475ex" height="2.289ex" role="img" focusable="false" viewBox="0 -846 3745.8 1011.6" aria-hidden="true"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math"><g data-mml-node="mi"><path data-c="1D434" d="M208 74Q208 50 254 46Q272 46 272 35Q272 34 270 22Q267 8 264 4T251 0Q249 0 239 0T205 1T141 2Q70 2 50 0H42Q35 7 35 11Q37 38 48 46H62Q132 49 164 96Q170 102 345 401T523 704Q530 716 547 716H555H572Q578 707 578 706L606 383Q634 60 636 57Q641 46 701 46Q726 46 726 36Q726 34 723 22Q720 7 718 4T704 0Q701 0 690 0T651 1T578 2Q484 2 455 0H443Q437 6 437 9T439 27Q443 40 445 43L449 46H469Q523 49 533 63L521 213H283L249 155Q208 86 208 74ZM516 260Q516 271 504 416T490 562L463 519Q447 492 400 412L310 260L413 259Q516 259 516 260Z" style="stroke-width: 3;"/></g><g data-mml-node="mo" transform="translate(972.2,0)"><path data-c="2229" d="M88 -21T75 -21T55 -7V200Q55 231 55 280Q56 414 60 428Q61 430 61 431Q77 500 152 549T332 598Q443 598 522 544T610 405Q611 399 611 194V-7Q604 -22 591 -22Q582 -22 572 -9L570 405Q563 433 556 449T529 485Q498 519 445 538T334 558Q251 558 179 518T96 401Q95 396 95 193V-7Q88 -21 75 -21Z" style="stroke-width: 3;"/></g><g data-mml-node="msub" transform="translate(1861.4,0)"><g data-mml-node="mi"><path data-c="2201" d="M404 269Q412 269 418 267T428 261T435 253T441 245L444 240V172Q444 103 443 96Q440 81 431 65T403 27T344 -7T250 -21T156 -8T97 27T69 65T58 96Q56 103 56 413Q56 722 58 729Q74 822 215 845Q221 846 229 846H243Q282 846 290 845Q422 826 443 729Q444 722 444 653V586L442 583Q441 580 440 578T436 573T430 567T423 562T415 558T404 556Q377 556 367 583Q364 590 364 654V719Q363 721 360 726T355 733Q326 766 250 766H249Q235 766 219 765T174 752T137 719V107Q145 83 178 71T251 58H254Q340 58 364 107V172Q364 176 364 187T363 204Q363 269 404 269Z" style="stroke-width: 3;"/></g><g data-mml-node="mi" transform="translate(533,-150) scale(0.707)"><path data-c="1D448" d="M107 637Q73 637 71 641Q70 643 70 649Q70 673 81 682Q83 683 98 683Q139 681 234 681Q268 681 297 681T342 682T362 682Q378 682 378 672Q378 670 376 658Q371 641 366 638H364Q362 638 359 638T352 638T343 637T334 637Q295 636 284 634T266 623Q265 621 238 518T184 302T154 169Q152 155 152 140Q152 86 183 55T269 24Q336 24 403 69T501 205L552 406Q599 598 599 606Q599 633 535 637Q511 637 511 648Q511 650 513 660Q517 676 519 679T529 683Q532 683 561 682T645 680Q696 680 723 681T752 682Q767 682 767 672Q767 650 759 642Q756 637 737 637Q666 633 648 597Q646 592 598 404Q557 235 548 205Q515 105 433 42T263 -22Q171 -22 116 34T60 167V183Q60 201 115 421Q164 622 164 628Q164 635 107 637Z" style="stroke-width: 3;"/></g></g><g data-mml-node="mi" transform="translate(2986.8,0)"><path data-c="1D435" d="M231 637Q204 637 199 638T194 649Q194 676 205 682Q206 683 335 683Q594 683 608 681Q671 671 713 636T756 544Q756 480 698 429T565 360L555 357Q619 348 660 311T702 219Q702 146 630 78T453 1Q446 0 242 0Q42 0 39 2Q35 5 35 10Q35 17 37 24Q42 43 47 45Q51 46 62 46H68Q95 46 128 49Q142 52 147 61Q150 65 219 339T288 628Q288 635 231 637ZM649 544Q649 574 634 600T585 634Q578 636 493 637Q473 637 451 637T416 636H403Q388 635 384 626Q382 622 352 506Q352 503 351 500L320 374H401Q482 374 494 376Q554 386 601 434T649 544ZM595 229Q595 273 572 302T512 336Q506 337 429 337Q311 337 310 336Q310 334 293 263T258 122L240 52Q240 48 252 48T333 46Q422 46 429 47Q491 54 543 105T595 229Z" style="stroke-width: 3;"/></g></g></g></svg><mjx-assistive-mml unselectable="on" display="inline" style="top: 0px; left: 0px; clip: rect(1px, 1px, 1px, 1px); -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; position: absolute; padding: 1px 0px 0px 0px; border: 0px; display: block; width: auto; overflow: hidden;"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>A</mi><mo>∩</mo><msub><mi>∁</mi><mi>U</mi></msub><mi>B</mi></math></mjx-assistive-mml></mjx-container> （<mjx-container v-pre class="MathJax" jax="SVG" style="direction: ltr; position: relative;"><svg style="overflow: visible; min-height: 1px; min-width: 1px; vertical-align: -0.05ex;" xmlns="http://www.w3.org/2000/svg" width="5.929ex" height="2.312ex" role="img" focusable="false" viewBox="0 -1000 2620.4 1022" aria-hidden="true"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math"><g data-mml-node="mi"><path data-c="1D434" d="M208 74Q208 50 254 46Q272 46 272 35Q272 34 270 22Q267 8 264 4T251 0Q249 0 239 0T205 1T141 2Q70 2 50 0H42Q35 7 35 11Q37 38 48 46H62Q132 49 164 96Q170 102 345 401T523 704Q530 716 547 716H555H572Q578 707 578 706L606 383Q634 60 636 57Q641 46 701 46Q726 46 726 36Q726 34 723 22Q720 7 718 4T704 0Q701 0 690 0T651 1T578 2Q484 2 455 0H443Q437 6 437 9T439 27Q443 40 445 43L449 46H469Q523 49 533 63L521 213H283L249 155Q208 86 208 74ZM516 260Q516 271 504 416T490 562L463 519Q447 492 400 412L310 260L413 259Q516 259 516 260Z" style="stroke-width: 3;"/></g><g data-mml-node="mo" transform="translate(972.2,0)"><path data-c="2229" d="M88 -21T75 -21T55 -7V200Q55 231 55 280Q56 414 60 428Q61 430 61 431Q77 500 152 549T332 598Q443 598 522 544T610 405Q611 399 611 194V-7Q604 -22 591 -22Q582 -22 572 -9L570 405Q563 433 556 449T529 485Q498 519 445 538T334 558Q251 558 179 518T96 401Q95 396 95 193V-7Q88 -21 75 -21Z" style="stroke-width: 3;"/></g><g data-mml-node="mover" transform="translate(1861.4,0)"><g data-mml-node="mi"><path data-c="1D435" d="M231 637Q204 637 199 638T194 649Q194 676 205 682Q206 683 335 683Q594 683 608 681Q671 671 713 636T756 544Q756 480 698 429T565 360L555 357Q619 348 660 311T702 219Q702 146 630 78T453 1Q446 0 242 0Q42 0 39 2Q35 5 35 10Q35 17 37 24Q42 43 47 45Q51 46 62 46H68Q95 46 128 49Q142 52 147 61Q150 65 219 339T288 628Q288 635 231 637ZM649 544Q649 574 634 600T585 634Q578 636 493 637Q473 637 451 637T416 636H403Q388 635 384 626Q382 622 352 506Q352 503 351 500L320 374H401Q482 374 494 376Q554 386 601 434T649 544ZM595 229Q595 273 572 302T512 336Q506 337 429 337Q311 337 310 336Q310 334 293 263T258 122L240 52Q240 48 252 48T333 46Q422 46 429 47Q491 54 543 105T595 229Z" style="stroke-width: 3;"/></g><g data-mml-node="mo" transform="translate(0,615)"><svg width="759" height="237" x="0" y="148" viewBox="189.8 148 759 237"><path data-c="2013" d="M0 248V285H499V248H0Z" transform="scale(2.277,1)" style="stroke-width: 3;"/></svg></g></g></g></g></svg><mjx-assistive-mml unselectable="on" display="inline" style="top: 0px; left: 0px; clip: rect(1px, 1px, 1px, 1px); -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; position: absolute; padding: 1px 0px 0px 0px; border: 0px; display: block; width: auto; overflow: hidden;"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>A</mi><mo>∩</mo><mover><mi>B</mi><mo accent="true">―</mo></mover></math></mjx-assistive-mml></mjx-container>）</p>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::vkvtj9e4y7nfflqoj8r0ce::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    int n, m;
    while (cin &gt;&gt; n) {
        cin &gt;&gt; m;
        vector&lt;int&gt; a, b;

        if (n == 0 and m == 0) {
            return 0;
        }

        int _number;
        while (n &gt; 0) {
            n--;
            cin &gt;&gt; _number;
            a.push_back(_number);
        }
        while (m &gt; 0) {
            m--;
            cin &gt;&gt; _number;
            b.push_back(_number);
        }

        sort(a.begin(), a.end());
        sort(b.begin(), b.end());
        bool flag = false;
        for (int number : a) {
            if (!binary_search(b.begin(), b.end(), number)) {
                cout &lt;&lt; number &lt;&lt; &quot; &quot;;
                flag = true;
            }
        }
        if (flag == false) {
            cout &lt;&lt; &quot;NULL&quot;;
        }
        cout &lt;&lt; endl;
    }

    return 0;
}</code></pre>
</div><h3 id="k-题-2" tabindex="-1">K 题 <a class="header-anchor" href="#k-题-2" aria-label="Permalink to “K 题”">&#8203;</a></h3>
<p>24.9.22 凌晨更新题解</p>
<p>原题链接：<a href="https://acm.hdu.edu.cn/showproblem.php?pid=1004" target="_blank" rel="noreferrer">HDU 1004</a></p>
<p>在一个字典内统计出现次数，
最后遍历找出出现次数最多的输出即可</p>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::puymxneljl92muxm4aosln::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    int n;
    string bn;
    while (cin &gt;&gt; n) {
        if (n == 0) {
            return 0;
        }

        map&lt;string, int&gt; m;

        while (n &gt; 0) {
            n--;
            cin &gt;&gt; bn;
            if (m.find(bn) == m.end()) {
                m[bn] = 1;
            } else {
                m[bn] += 1;
            }
        }

        string answer_name;
        int answer_times = 0;
        for (map&lt;string, int&gt;::iterator it = m.begin(); it != m.end(); it++) {
            if (it-&gt;second &gt; answer_times) {
                answer_times = it-&gt;second;
                answer_name = it-&gt;first;
            }
        }

        cout &lt;&lt; answer_name &lt;&lt; endl;
    }
    return 0;
}</code></pre>
</div><h3 id="l-题-1" tabindex="-1">L 题 <a class="header-anchor" href="#l-题-1" aria-label="Permalink to “L 题”">&#8203;</a></h3>
<p>24.9.22 凌晨更新题解</p>
<p>原题链接：<a href="https://codeforces.com/problemset/problem/1722/C" target="_blank" rel="noreferrer">Codeforces 1722C</a></p>
<p>在一个字典中记录各单词出现次数，
最后再各自统计总分即可</p>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::r6kwxpkobtod3tw5vq66n::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    int t;
    cin &gt;&gt; t;
    while (t &gt; 0) {
        t--;
        int n_o;
        cin &gt;&gt; n_o;
        int n0 = n_o, n1 = n_o, n2 = n_o;
        string word0[1000], word1[1000], word2[1000];
        map&lt;string, int&gt; word_times;
        string word;
        while (n0 &gt; 0) {
            n0--;
            cin &gt;&gt; word;
            word0[n0] = word;
            if (word_times.find(word) == word_times.end()) {
                word_times[word] = 1;
            } else {
                word_times[word] += 1;
            }
        }
        while (n1 &gt; 0) {
            n1--;
            cin &gt;&gt; word;
            word1[n1] = word;
            if (word_times.find(word) == word_times.end()) {
                word_times[word] = 1;
            } else {
                word_times[word] += 1;
            }
        }
        while (n2 &gt; 0) {
            n2--;
            cin &gt;&gt; word;
            word2[n2] = word;
            if (word_times.find(word) == word_times.end()) {
                word_times[word] = 1;
            } else {
                word_times[word] += 1;
            }
        }
        int rt0 = 0;
        for (string _word : word0) {
            if (word_times[_word] == 1) {
                rt0 += 3;
            } else if (word_times[_word] == 2) {
                rt0 += 1;
            }
        }

        int rt1 = 0;
        for (string _word : word1) {
            if (word_times[_word] == 1) {
                rt1 += 3;
            } else if (word_times[_word] == 2) {
                rt1 += 1;
            }
        }

        int rt2 = 0;
        for (string _word : word2) {
            if (word_times[_word] == 1) {
                rt2 += 3;
            } else if (word_times[_word] == 2) {
                rt2 += 1;
            }
        }

        printf(&quot;%d %d %d\n&quot;, rt0, rt1, rt2);
    }

    return 0;
}</code></pre>
</div><h3 id="m-题" tabindex="-1">M 题 <a class="header-anchor" href="#m-题" aria-label="Permalink to “M 题”">&#8203;</a></h3>
<p>24.9.22 凌晨更新 TL 代码
24.9.23 晚上更新 AC 代码</p>
<p>原题链接：<a href="https://codeforces.com/problemset/problem/1790/D" target="_blank" rel="noreferrer">Codeforces 1790D</a></p>
<p>题单的制作者今天（24.9.23）给题目加了个提示，在标题里标注这个题需要用字典（map）数据结构。</p>
<p>经过查询和测试后得知字典（map）数据结构遍历时，键（key）是从小到大的，我重新实现了代码。
代码分为两部分，第一部分是将数据读入字典，第二部分（从 <code>int rt = 0;</code> 开始）是数据处理部分。
最后字典存储的键代表这个娃的大小，对应的值表示还有多少个这样的娃没用掉。</p>
<p>数据处理的思路是：</p>
<ol>
<li>遍历字典（根据键从小到大）</li>
<li>当检测到键对应的值大于 0（这里用 <code>while</code> 而不是 <code>if</code>，因为可以有多组套娃从同一个数开始），就召唤另一个迭代器（it_son），然后检查后继能否继续组成更长的套娃。
<ul>
<li>如果后继的键是前面的键 +1 且 键对应的值大于 0，说明可以组成更长的套娃。</li>
</ul>
</li>
<li>如果用了这个娃，就对应值 -1，表示用掉一个。</li>
<li>如果后继不满足组成更长的套娃的要求，那就退出循环并且最后统计结果的变量（rt）+1。</li>
</ol>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::c0etwwajsspej5dncfzms::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin &gt;&gt; t;
    while (t &gt; 0) {
        t--;
        int n;
        map&lt;int, int&gt; dict;
        cin &gt;&gt; n;

        while (n &gt; 0) {
            n--;
            int _number;
            cin &gt;&gt; _number;
            dict[_number]++;
        }

        int rt = 0;

        for (auto it = dict.begin(); it != dict.end(); it++) {
            while (it-&gt;second &gt; 0) {
                auto it_son = it;
                it_son++;
                int last_one = it-&gt;first;
                while (it_son-&gt;second &gt; 0 &amp;&amp; it_son-&gt;first - 1 == last_one) {
                    it_son-&gt;second--;
                    last_one = it_son-&gt;first;
                    it_son++;
                }
                rt++;
                it-&gt;second--;
            }
        }

        cout &lt;&lt; rt &lt;&lt; endl;
    }
    return 0;
}</code></pre>
</div><details><summary>这里折叠是代码是带 debug 的代码，将开头的 `bool debug = 1;` 改为 `bool debug = 0;` 即可 AC</summary>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::emqmf06s9c4kwbnm50l7xb::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;
bool debug = 1;
#define dbg(x)                                                   \
    if (debug)                                                   \
        cerr &lt;&lt; BRIGHT_CYAN &lt;&lt; #x &lt;&lt; COLOR_RESET &lt;&lt; &quot; = &quot; &lt;&lt; (x) \
             &lt;&lt; NORMAL_FAINT &lt;&lt; COLOR_RESET &lt;&lt; endl;
const string COLOR_RESET = &quot;\033[0m&quot;, BRIGHT_CYAN = &quot;\033[1;36m&quot;,
             NORMAL_FAINT = &quot;\033[0;2m&quot;;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin &gt;&gt; t;
    while (t &gt; 0) {
        t--;
        int n;
        map&lt;int, int&gt; dict;
        cin &gt;&gt; n;

        while (n &gt; 0) {
            n--;
            int _number;
            cin &gt;&gt; _number;
            dict[_number]++;
        }

        int rt = 0;

        for (auto it = dict.begin(); it != dict.end(); it++) {
            dbg(it-&gt;first);
            dbg(it-&gt;second);
            while (it-&gt;second &gt; 0) {
                auto it_son = it;
                it_son++;
                int last_one = it-&gt;first;
                while (it_son-&gt;second &gt; 0 &amp;&amp; it_son-&gt;first - 1 == last_one) {
                    dbg(it_son-&gt;first);
                    dbg(it_son-&gt;second);
                    it_son-&gt;second--;
                    last_one = it_son-&gt;first;
                    it_son++;
                }
                rt++;
                dbg(rt);
                it-&gt;second--;
            }
        }

        cout &lt;&lt; rt &lt;&lt; endl;
    }
    return 0;
}</code></pre>
</div></details>
<details>
<summary>先前 TL 的题解</summary>
<p>题解 Time limit exceeded on test 27</p>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::sva92tnhwwg2th4pjah1oa::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin &gt;&gt; t;
    while (t &gt; 0) {
        t--;
        int n;
        vector&lt;int&gt; v, st, temp_st;
        cin &gt;&gt; n;

        while (n &gt; 0) {
            n--;
            int _number;
            cin &gt;&gt; _number;
            temp_st.push_back(_number);
        }
        sort(temp_st.begin(), temp_st.end());

        if (temp_st.front() == temp_st.back()) {
            cout &lt;&lt; temp_st.size() &lt;&lt; endl;
            continue;
        }

        int rt = 0;
        do {
            v = temp_st;
            temp_st.clear();

            for (int _number : v) {
                if (st.size() != 0) {
                    int _back = st.back();
                    if (_back == _number) {
                        temp_st.push_back(_number);
                    } else if (_back + 1 == _number) {
                        st.push_back(_number);
                    } else {
                        rt++;
                        st.clear();
                        st.push_back(_number);
                    }
                } else {
                    st.push_back(_number);
                }
            }

            if (st.size() != 0) {
                rt++;
                st.clear();
            }

        } while (temp_st.size() != 0);

        cout &lt;&lt; rt &lt;&lt; endl;
    }
    return 0;
}</code></pre>
</div></details>
<h3 id="n-题" tabindex="-1">N 题 <a class="header-anchor" href="#n-题" aria-label="Permalink to “N 题”">&#8203;</a></h3>
<p>24.9.22 下午更新 TL 代码
24.9.23 下午更新 AC 代码</p>
<p>原题链接：<a href="https://codeforces.com/problemset/problem/1800/C2" target="_blank" rel="noreferrer">Codeforces 1800C2</a></p>
<p>虽然我不会实现最大堆，但是经过检索找到了一个 <code>priority_queue</code> 容器类，默认实现就是最大堆。我把原本 <code>vector</code>+<code>sort</code> 函数的模式改成 <code>priority_queue</code> 就成功 AC 了。</p>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::jwlcmtfrxl954uc4fzukwi::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin &gt;&gt; t;
    while (t &gt; 0) {
        t--;
        int n;
        ll rt = 0;
        cin &gt;&gt; n;
        priority_queue&lt;int&gt; st;
        int _number;
        while (n &gt; 0) {
            n--;
            cin &gt;&gt; _number;
            if (_number != 0) {
                st.push(_number);
            } else if (st.size() != 0) {
                rt += st.top();
                st.pop();
            }
        }
        cout &lt;&lt; rt &lt;&lt; endl;
    }

    return 0;
}</code></pre>
</div><h3 id="o-题" tabindex="-1">O 题 <a class="header-anchor" href="#o-题" aria-label="Permalink to “O 题”">&#8203;</a></h3>
<p>最基础的 10 转 2 进制</p>
<p>原题链接：<a href="https://acm.hdu.edu.cn/showproblem.php?pid=2051" target="_blank" rel="noreferrer">HDU 2051</a></p>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::wq9j392z96kzxbybhdid::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;

    while (cin &gt;&gt; n) {
        vector&lt;int&gt; v;
        if (n == 0) {
            v.push_back(0);
        }
        while (n &gt; 0) {
            if (n % 2 == 0) {
                v.push_back(0);
                n /= 2;
            } else {
                v.push_back(1);
                n /= 2;
            }
        }

        while (v.size() != 0) {
            cout &lt;&lt; v.back();
            v.pop_back();
        }
        cout &lt;&lt; endl;
    }

    return 0;
}</code></pre>
</div><p>网上冲浪的时候找到的另一种 Cpp 题解，巧妙的利用了递归，分享一下</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::moysu9suzkkvwmmam57i4j::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;

void D2B(int d) {
    if (d / 2) D2B(d / 2);
    cout &lt;&lt; d % 2;
}

int main() {
    int n;

    while (cin &gt;&gt; n) {
        D2B(n);
        cout &lt;&lt; endl;
    }

    return 0;
}</code></pre>
</div><h2 id="hrbust-acm-练习-2024-级第-5-周题单-题解分享-a-c-f-h" tabindex="-1">Hrbust ACM 练习 2024 级第 5 周题单 题解分享 (A-C,F-H) <a class="header-anchor" href="#hrbust-acm-练习-2024-级第-5-周题单-题解分享-a-c-f-h" aria-label="Permalink to “Hrbust ACM 练习 2024 级第 5 周题单 题解分享 (A-C,F-H)”">&#8203;</a></h2>
<h3 id="前言-3" tabindex="-1">前言 <a class="header-anchor" href="#前言-3" aria-label="Permalink to “前言”">&#8203;</a></h3>
<p>题单链接：<a href="https://vjudge.net/contest/657265" target="_blank" rel="noreferrer">2024 级第 5 周题单 - Virtual Judge (vjudge.net)</a></p>
<h3 id="a-题-3" tabindex="-1">A 题 <a class="header-anchor" href="#a-题-3" aria-label="Permalink to “A 题”">&#8203;</a></h3>
<p>原题链接：<a href="https://atcoder.jp/contests/abc339/tasks/abc339_c?lang=en" target="_blank" rel="noreferrer">ABC 339C</a></p>
<p>Python Code</p>
<div class="language-python" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::5mg9jo3n0r9smwv0si2fn9::--><code>from itertools import accumulate

input()
min_number = 0
last_number = 0

for n in accumulate(map(int, input().split())):
    if n &lt; min_number:
        min_number = n
    last_number = n

if min_number &lt; 0:
    min_number = -min_number
    print(min_number + last_number)
else:
    print(last_number)</code></pre>
</div><h3 id="b-题-3" tabindex="-1">B 题 <a class="header-anchor" href="#b-题-3" aria-label="Permalink to “B 题”">&#8203;</a></h3>
<p>原题链接：<a href="https://www.luogu.com.cn/problem/P3397" target="_blank" rel="noreferrer">P3397</a></p>
<p>Python Code</p>
<div class="language-python" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::bv2l00tnuqszfg6g94f3::--><code>from itertools import accumulate


n, m = map(int, input().split())
l = []
for _m in range(n):
    l.append([])
    for _ in range(n + 1):
        l[_m].append(0)

while m &gt; 0:
    m -= 1
    x1, y1, x2, y2 = map(int, input().split())
    for x in range(x1 - 1, x2):
        l[x][y1 - 1] += 1
        l[x][y2] -= 1

for sl in l:
    print(*list(accumulate(sl[:-1])))</code></pre>
</div><h3 id="c-题-3" tabindex="-1">C 题 <a class="header-anchor" href="#c-题-3" aria-label="Permalink to “C 题”">&#8203;</a></h3>
<p>原题链接：<a href="https://www.luogu.com.cn/problem/P2280" target="_blank" rel="noreferrer">P2280 [HNOI2003] 激光炸弹 - 洛谷</a></p>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::xy8pbkslg5y3afrfrgy8::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int o[5010][5010];

void add(int x, int y, int v) { o[x][y] += v; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, r, x, y, v;
    cin &gt;&gt; n &gt;&gt; r;
    int max_x = r, max_y = r;

    for (int i = 0; i &lt; n; i++) {
        cin &gt;&gt; x &gt;&gt; y &gt;&gt; v;
        x++;    // x 和 y 索引都加一，避免越界
        y++;
        if (x &gt; max_x) {
            max_x = x;
        }
        if (y &gt; max_y) {
            max_y = y;
        }
        add(x, y, v);
    }
    for (int _x = 1; _x &lt;= max_x; _x++) {
        for (int _y = 1; _y &lt;= max_y; _y++) {
            o[_x][_y] =
                o[_x][_y] + o[_x - 1][_y] + o[_x][_y - 1] - o[_x - 1][_y - 1];
        }
    }
    int rt = 0;
    for (int _x = r; _x &lt;= max_x; _x++) {
        for (int _y = r; _y &lt;= max_y; _y++) {
            rt = max(rt, o[_x][_y] - o[_x - r][_y] - o[_x][_y - r] +
                             o[_x - r][_y - r]);
        }
    }
    cout &lt;&lt; rt;
    return 0;
}</code></pre>
</div><p>Cpp Code 另一种实现</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::ll7ycs2wyjhfwwxfreo8t::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int o[5010][5010];

void add(int x, int y, int v) { o[x][y] += v; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, r, x, y, v;
    cin &gt;&gt; n &gt;&gt; r;
    int max_x = r, max_y = r;

    for (int i = 0; i &lt; n; i++) {
        cin &gt;&gt; x &gt;&gt; y &gt;&gt; v;
        if (x &gt; max_x) {
            max_x = x;
        }
        if (y &gt; max_y) {
            max_y = y;
        }
        add(x, y, v);
    }

    // 计算 y=0 这一列上的前缀和
    for (int i = 1; i &lt;= max_x; i++) {
        o[i][0] += o[i - 1][0];
    }
    // 计算 x=0 这一行上的前缀和
    for (int j = 1; j &lt;= max_y; j++) {
        o[0][j] += o[0][j - 1];
    }
    // 从 (1,1) 开始计算前缀和
    for (int _x = 1; _x &lt;= max_x; _x++) {
        for (int _y = 1; _y &lt;= max_y; _y++) {
            o[_x][_y] =
                o[_x][_y] + o[_x - 1][_y] + o[_x][_y - 1] - o[_x - 1][_y - 1];
        }
    }

    int rt = 0;
    // 从 索引 (r-1，r-1) 开始计算矩阵内数字和（索引 0 到 r-1 长度为 r）
    for (int _x = r - 1; _x &lt;= max_x; _x++) {
        for (int _y = r - 1; _y &lt;= max_y; _y++) {
            int v1, v2, v3, v4;
            v1 = o[_x][_y];

            // 越界判定，防止索引小于 0
            if (_x - r &lt; 0) {
                // 说明：负索引前缀和都是 0
                // 举个例子原数组 1,0,2,3
                // 对应前缀和 1,1,3,6
                // 现在问索引 -1 的前缀和
                // 那原数组其实就变成了 0,1,0,2,3
                // 对应前缀和 0,1,1,3,6（对应索引 -1,0,1,2,3）
                v2 = 0;
            } else {
                v2 = o[_x - r][_y];
            }

            if (_y - r &lt; 0) {
                v3 = 0;
            } else {
                v3 = o[_x][_y - r];
            }

            if (_y - r &lt; 0 or _x - r &lt; 0) {
                v4 = 0;
            } else {
                v4 = o[_x - r][_y - r];
            }

            rt = max(rt, v1 - v2 - v3 + v4);
        }
    }
    cout &lt;&lt; rt;
    return 0;
}</code></pre>
</div><h3 id="d-题-3" tabindex="-1">D 题 <a class="header-anchor" href="#d-题-3" aria-label="Permalink to “D 题”">&#8203;</a></h3>
<p>Python Code</p>
<div class="language-python" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::k4orr6xs76pehqb3jcywaa::--><code></code></pre>
</div><h3 id="e-题-3" tabindex="-1">E 题 <a class="header-anchor" href="#e-题-3" aria-label="Permalink to “E 题”">&#8203;</a></h3>
<p>Python Code</p>
<div class="language-python" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::mduy7dm1agh84q41eq3yo::--><code></code></pre>
</div><h3 id="f-题-3" tabindex="-1">F 题 <a class="header-anchor" href="#f-题-3" aria-label="Permalink to “F 题”">&#8203;</a></h3>
<p>原题链接：<a href="https://codeforces.com/problemset/problem/670/C" target="_blank" rel="noreferrer">CF670C</a></p>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::20jqsenkgm8r2a6wktt8yl::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

const long long N = 200000 + 10;
ll scientist_language[N], moive_voice[N], moive_subtitle[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin &gt;&gt; n;                        // n = 科学家的数量
    map&lt;ll, ll&gt; scientist_language;  // language_index -&gt; scientist_number
    for (ll i = 1; i &lt;= n; i++) {
        ll language_index;
        cin &gt;&gt; language_index;
        scientist_language[language_index] += 1;
    }
    ll m;
    cin &gt;&gt; m;  // m = 电影院里的电影数量
    for (ll i = 1; i &lt;= m; i++) {
        ll vocie_language;
        cin &gt;&gt; vocie_language;
        moive_voice[i] = vocie_language;  // index 用 1 到 m
    }
    for (ll i = 1; i &lt;= m; i++) {
        ll subtitle_language;
        cin &gt;&gt; subtitle_language;
        moive_subtitle[i] = subtitle_language;  // index 用 1 到 m
    }

    ll very_satisfied = 0;
    ll almost_satisfied = 0;
    ll movie_index = 1;  //  默认值为 1
    for (ll i = 1; i &lt;= m; i++) {
        ll temp_almost_satisfied = scientist_language[moive_subtitle[i]];
        ll temp_very_satisfied = scientist_language[moive_voice[i]];
        if (temp_very_satisfied &gt; very_satisfied) {
            movie_index = i;
            very_satisfied = temp_very_satisfied;
            // almost_satisfied 也要记得更新，否则会错
            almost_satisfied = temp_almost_satisfied;
        } else if (temp_very_satisfied == very_satisfied &amp;&amp;
                   temp_almost_satisfied &gt; almost_satisfied) {
            movie_index = i;
            almost_satisfied = temp_almost_satisfied;
        }
    }

    cout &lt;&lt; movie_index &lt;&lt; endl;
    return 0;
}</code></pre>
</div><p>Cpp Code 另一种实现</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::4t2o3l9zxklt2vj42a6d6e::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

const long long N = 200000 + 10;
ll scientist_language[N], moive_voice[N], moive_subtitle[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin &gt;&gt; n;                        // n = 科学家的数量
    map&lt;ll, ll&gt; scientist_language;  // language_index -&gt; scientist_number
    for (ll i = 1; i &lt;= n; i++) {
        ll language_index;
        cin &gt;&gt; language_index;
        scientist_language[language_index] += 1;
    }
    ll m;
    cin &gt;&gt; m;  // m = 电影院里的电影数量
    for (ll i = 1; i &lt;= m; i++) {
        ll vocie_language;
        cin &gt;&gt; vocie_language;
        moive_voice[i] = vocie_language;  // index 用 1 到 m
    }
    for (ll i = 1; i &lt;= m; i++) {
        ll subtitle_language;
        cin &gt;&gt; subtitle_language;
        moive_subtitle[i] = subtitle_language;  // index 用 1 到 m
    }

    ll very_satisfied = 0;
    ll movie_index = 1;  //  默认值为 1
    for (ll i = 1; i &lt;= m; i++) {
        ll temp = scientist_language[moive_voice[i]];
        if (temp &gt; very_satisfied) {
            very_satisfied = temp;
            movie_index = i;  // 记录电影编号
        }
    }
    ll almost_satisfied = 0;
    for (ll i = 1; i &lt;= m; i++) {
        ll temp_voice = scientist_language[moive_voice[i]];
        ll temp_subtitle = scientist_language[moive_subtitle[i]];
        if (very_satisfied == temp_voice &amp;&amp; almost_satisfied &lt; temp_subtitle) {
            almost_satisfied = temp_subtitle;
            movie_index = i;
        }
    }

    cout &lt;&lt; movie_index &lt;&lt; endl;
    return 0;
}</code></pre>
</div><h3 id="g-题-3" tabindex="-1">G 题 <a class="header-anchor" href="#g-题-3" aria-label="Permalink to “G 题”">&#8203;</a></h3>
<p>原题链接：<a href="https://atcoder.jp/contests/abc014/tasks/abc014_3" target="_blank" rel="noreferrer">ABC 014C</a></p>
<p>Python Code</p>
<div class="language-python" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::pnqxnwrux7d46ev7dpa5vm::--><code>from itertools import accumulate

n = int(input())
l = [0] * (1000000 + 2)
while n &gt; 0:
    n -= 1
    a, b = map(int, input().split())
    l[a] += 1
    l[b + 1] -= 1
print(max(accumulate(l)))</code></pre>
</div><h3 id="h-题-3" tabindex="-1">H 题 <a class="header-anchor" href="#h-题-3" aria-label="Permalink to “H 题”">&#8203;</a></h3>
<p>原题链接：<a href="https://atcoder.jp/contests/abc035/tasks/abc035_c" target="_blank" rel="noreferrer">ABC 035C</a></p>
<p>试了一下 <a href="https://atcoder.jp/" target="_blank" rel="noreferrer">AtCoder</a>，这个判题机是很奇葩的。之前用 <code>print(rt, end=&quot;&quot;)</code> 会 WA。看了别人的博客才知道这个网站的老题有 bug，在程序输出结束后不进行换行是会 WA 的。新题目已修复。</p>
<div class="language-python" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::k7d08024z228e21ab34im::--><code>from itertools import accumulate


n, q = map(int, input().split())
l = []
for _ in range(0, n + 2):
    l.append(1)

while q &gt; 0:
    q -= 1
    li, ri = map(int, input().split())
    l[li - 1] *= -1
    l[ri] *= -1
_n = 0
last_one = 0
rt = &quot;&quot;
for i in range(0, n):
    if _n == n:
        break
    if l[i] == -1:  # 和前一个不一样
        if i == 0 or last_one == 0:
            last_one = 1
        else:
            last_one = 0
        rt += str(last_one)
    else:  # 和前一个一样
        rt += str(last_one)
    _n += 1
print(rt)</code></pre>
</div><h2 id="hrbust-acm-编程练习-20240922-题解分享" tabindex="-1">Hrbust ACM 编程练习 20240922 题解分享 <a class="header-anchor" href="#hrbust-acm-编程练习-20240922-题解分享" aria-label="Permalink to “Hrbust ACM 编程练习 20240922 题解分享”">&#8203;</a></h2>
<h3 id="前言-4" tabindex="-1">前言 <a class="header-anchor" href="#前言-4" aria-label="Permalink to “前言”">&#8203;</a></h3>
<p>题单链接：<a href="http://acm.hrbust.edu.cn/contests/index.php?act=login&amp;cid=2365" target="_blank" rel="noreferrer">编程练习 20240922 @ Hrbust Online Judge</a></p>
<h3 id="a-题-4" tabindex="-1">A 题 <a class="header-anchor" href="#a-题-4" aria-label="Permalink to “A 题”">&#8203;</a></h3>
<p><code>d</code> 的数据类型要用 <code>double</code> 而不是 <code>float</code> ，否则最后计算的答案会有精度损失。</p>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::qdgklukzygln2gllvm7i::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin &gt;&gt; t;
    while (t &gt; 0) {
        t--;
        int p, w, s;
        double d = 0;
        cin &gt;&gt; p &gt;&gt; w &gt;&gt; s;
        if (s &lt; 250) {
            d = 0;
        } else if (s &lt; 500) {
            d = 0.02;
        } else if (s &lt; 1000) {
            d = 0.05;
        } else if (s &lt; 2000) {
            d = 0.08;
        } else if (s &lt; 3000) {
            d = 0.1;
        } else {
            d = 0.15;
        }
        cout &lt;&lt; fixed &lt;&lt; setprecision(3) &lt;&lt; 1.0 * p * w * s * (1 - d);
        cout &lt;&lt; endl;
    }
    return 0;
}</code></pre>
</div><h3 id="b-题-4" tabindex="-1">B 题 <a class="header-anchor" href="#b-题-4" aria-label="Permalink to “B 题”">&#8203;</a></h3>
<p>打表代码</p>
<p>Python Code</p>
<div class="language-python" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::0cefzqumnbjn81zn1rw5nce::--><code>l = []
for i in range(-9, 9 + 1):
    temp_l = []
    for _ in range(1, 9 + 1):
        temp_l.append(0)
    l.append(temp_l)

for a in range(-9, 9 + 1):
    for n in range(1, 9 + 1):
        sum = 0
        for le in range(1, n + 1):
            sum += int(le * &quot;1&quot;) * a
        l[a + 9][n - 1] = sum
print(l)</code></pre>
</div><p>以上代码输出</p>
<!-- markdownlint-disable MD013 -->
<div class="language-log" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">log</span><pre><!--::markdown-it-async::tptikbqw5432kl4n6fo3t::--><code>[[-9, -108, -1107, -11106, -111105, -1111104, -11111103, -111111102, -1111111101], [-8, -96, -984, -9872, -98760, -987648, -9876536, -98765424, -987654312], [-7, -84, -861, -8638, -86415, -864192, -8641969, -86419746, -864197523], [-6, -72, -738, -7404, -74070, -740736, -7407402, -74074068, -740740734], [-5, -60, -615, -6170, -61725, -617280, -6172835, -61728390, -617283945], [-4, -48, -492, -4936, -49380, -493824, -4938268, -49382712, -493827156], [-3, -36, -369, -3702, -37035, -370368, -3703701, -37037034, -370370367], [-2, -24, -246, -2468, -24690, -246912, -2469134, -24691356, -246913578], [-1, -12, -123, -1234, -12345, -123456, -1234567, -12345678, -123456789], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 12, 123, 1234, 12345, 123456, 1234567, 12345678, 123456789], [2, 24, 246, 2468, 24690, 246912, 2469134, 24691356, 246913578], [3, 36, 369, 3702, 37035, 370368, 3703701, 37037034, 370370367], [4, 48, 492, 4936, 49380, 493824, 4938268, 49382712, 493827156], [5, 60, 615, 6170, 61725, 617280, 6172835, 61728390, 617283945], [6, 72, 738, 7404, 74070, 740736, 7407402, 74074068, 740740734], [7, 84, 861, 8638, 86415, 864192, 8641969, 86419746, 864197523], [8, 96, 984, 9872, 98760, 987648, 9876536, 98765424, 987654312], [9, 108, 1107, 11106, 111105, 1111104, 11111103, 111111102, 1111111101]]</code></pre>
</div><!-- markdownlint-enable MD013 -->
<p>用任意文本编辑器将<code>[</code>替换为<code>{</code>，<code>]</code>替换为<code>}</code>即可直接使用</p>
<p>AC 代码</p>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::an2ac8pgf2ihgb724tclb6::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int ans[][9] = {
    {-9, -108, -1107, -11106, -111105, -1111104, -11111103, -111111102,
     -1111111101},
    {-8, -96, -984, -9872, -98760, -987648, -9876536, -98765424, -987654312},
    {-7, -84, -861, -8638, -86415, -864192, -8641969, -86419746, -864197523},
    {-6, -72, -738, -7404, -74070, -740736, -7407402, -74074068, -740740734},
    {-5, -60, -615, -6170, -61725, -617280, -6172835, -61728390, -617283945},
    {-4, -48, -492, -4936, -49380, -493824, -4938268, -49382712, -493827156},
    {-3, -36, -369, -3702, -37035, -370368, -3703701, -37037034, -370370367},
    {-2, -24, -246, -2468, -24690, -246912, -2469134, -24691356, -246913578},
    {-1, -12, -123, -1234, -12345, -123456, -1234567, -12345678, -123456789},
    {0, 0, 0, 0, 0, 0, 0, 0, 0},
    {1, 12, 123, 1234, 12345, 123456, 1234567, 12345678, 123456789},
    {2, 24, 246, 2468, 24690, 246912, 2469134, 24691356, 246913578},
    {3, 36, 369, 3702, 37035, 370368, 3703701, 37037034, 370370367},
    {4, 48, 492, 4936, 49380, 493824, 4938268, 49382712, 493827156},
    {5, 60, 615, 6170, 61725, 617280, 6172835, 61728390, 617283945},
    {6, 72, 738, 7404, 74070, 740736, 7407402, 74074068, 740740734},
    {7, 84, 861, 8638, 86415, 864192, 8641969, 86419746, 864197523},
    {8, 96, 984, 9872, 98760, 987648, 9876536, 98765424, 987654312},
    {9, 108, 1107, 11106, 111105, 1111104, 11111103, 111111102, 1111111101}};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin &gt;&gt; t;
    while (t &gt; 0) {
        t--;
        int a, n;
        cin &gt;&gt; a &gt;&gt; n;
        cout &lt;&lt; ans[a + 9][n - 1];
        cout &lt;&lt; endl;
    }
    return 0;
}</code></pre>
</div><h3 id="c-题-4" tabindex="-1">C 题 <a class="header-anchor" href="#c-题-4" aria-label="Permalink to “C 题”">&#8203;</a></h3>
<p>打表代码</p>
<p>Python Code</p>
<div class="language-python" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::6rua12eqdd8wfah4fh6jlc::--><code>for i in range(1000):
    if (i**2) &lt;= 1000000:
        if str(i**2).endswith(str(i)):
            print(i**2, end=&quot;,&quot;)</code></pre>
</div><p>以上代码输出</p>
<div class="language-log" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">log</span><pre><!--::markdown-it-async::mzxply5db8caig06kms1::--><code>0,1,25,36,625,5776,141376,390625,</code></pre>
</div><p>AC 代码</p>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::4x3965y20zo7c1voxgww4u::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int ans[] = {0, 1, 25, 36, 625, 5776, 141376, 390625};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin &gt;&gt; t;
    while (t &gt; 0) {
        t--;
        int a, b;
        cin &gt;&gt; a &gt;&gt; b;
        bool flag = true;
        for (int number : ans) {
            if (number &lt;= b &amp;&amp; number &gt;= a) {
                // 避免输出多余空格的设计
                if (flag) {
                    cout &lt;&lt; number;
                    flag = false;
                } else {
                    cout &lt;&lt; &quot; &quot; &lt;&lt; number;
                }
            }
        }
        cout &lt;&lt; endl;
    }
    return 0;
}</code></pre>
</div><h3 id="d-题-4" tabindex="-1">D 题 <a class="header-anchor" href="#d-题-4" aria-label="Permalink to “D 题”">&#8203;</a></h3>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::jvzghg67h5lxyoj1oxk9rc::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin &gt;&gt; n;
    while (n &gt; 0) {
        n--;
        int a, b;
        cin &gt;&gt; a &gt;&gt; b;
        vector&lt;int&gt; l;
        bool start_flag = true;
        for (int i = a; i &lt;= b; i++) {
            if (i % 3 != 0) {
                if (start_flag) {
                    cout &lt;&lt; i;
                    start_flag = false;
                    continue;
                }
                cout &lt;&lt; &quot; &quot; &lt;&lt; i;
            }
        }
        cout &lt;&lt; endl;
    }

    return 0;
}</code></pre>
</div><h3 id="e-题-4" tabindex="-1">E 题 <a class="header-anchor" href="#e-题-4" aria-label="Permalink to “E 题”">&#8203;</a></h3>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::dx2zujjcw8varuytb4xrd9::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin &gt;&gt; t;
    while (t &gt; 0) {
        t--;
        int a;
        cin &gt;&gt; a;
        int max_line = 2 * a - 1;
        for (int i = 1; i &lt;= max_line; i += 2) {
            for (int ii = 0; ii &lt;= ((max_line - i) / 2) - 1; ii++) {
                cout &lt;&lt; &quot; &quot;;
            }
            for (int iii = 0; iii &lt;= i - 1; iii++) {
                cout &lt;&lt; &quot;*&quot;;
            }

            cout &lt;&lt; endl;
        }
        for (int i = max_line; i &gt; 1; i -= 2) {
            for (int ii = (max_line - i) / 2 + 1; ii &gt; 0; ii--) {
                cout &lt;&lt; &quot; &quot;;
            }
            for (int iii = (i - 1) - 1; iii &gt; 0; iii--) {
                cout &lt;&lt; &quot;*&quot;;
            }

            cout &lt;&lt; endl;
        }
    }
    return 0;
}</code></pre>
</div><h3 id="f-题-4" tabindex="-1">F 题 <a class="header-anchor" href="#f-题-4" aria-label="Permalink to “F 题”">&#8203;</a></h3>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::csvlypjzynv6elsedxgt::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin &gt;&gt; t;
    while (t &gt; 0) {
        t--;
        int a;
        cin &gt;&gt; a;
        int max_line = 2 * a + 1;
        for (int i = 1; i &lt;= max_line; i += 2) {
            int c = (i + 1) / 2;
            for (int ii = 0; ii &lt;= ((max_line - i) / 2) - 1; ii++) {
                cout &lt;&lt; &quot; &quot;;
            }
            bool flag = false;
            for (int iii = 0; iii &lt;= i - 1; iii++) {
                cout &lt;&lt; c;
                if (c &gt; 1) {
                    if (flag) {
                        c++;
                    } else {
                        c--;
                    }
                } else if (c == 1) {
                    c++;
                    flag = true;
                }
            }

            cout &lt;&lt; endl;
        }
        for (int i = max_line; i &gt; 1; i -= 2) {
            int c = (i - 2 + 1) / 2;
            for (int ii = (max_line - i) / 2 + 1; ii &gt; 0; ii--) {
                cout &lt;&lt; &quot; &quot;;
            }
            bool flag = false;
            for (int iii = i - 2; iii &gt; 0; iii--) {
                cout &lt;&lt; c;
                if (c &gt; 1) {
                    if (flag) {
                        c++;
                    } else {
                        c--;
                    }
                } else if (c == 1) {
                    c++;
                    flag = true;
                }
            }

            cout &lt;&lt; endl;
        }
    }
    return 0;
}</code></pre>
</div><h3 id="g-题-4" tabindex="-1">G 题 <a class="header-anchor" href="#g-题-4" aria-label="Permalink to “G 题”">&#8203;</a></h3>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::zvgogqt7d09hazm64ab86c::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin &gt;&gt; t;
    while (t &gt; 0) {
        t--;
        int o_a, o_b, max_number = 0, ans_x = 0, ans_y = 0, a = 0;
        cin &gt;&gt; o_a &gt;&gt; o_b;
        while (a &lt; o_a) {
            a++;
            int b = 0;
            while (b &lt; o_b) {
                b++;
                int temp;
                cin &gt;&gt; temp;
                if (temp &gt; max_number) {
                    max_number = temp;
                    ans_x = a;
                    ans_y = b;
                }
            }
        }
        cout &lt;&lt; ans_x &lt;&lt; &quot; &quot; &lt;&lt; ans_y &lt;&lt; endl;
    }
    return 0;
}</code></pre>
</div><h3 id="h-题-4" tabindex="-1">H 题 <a class="header-anchor" href="#h-题-4" aria-label="Permalink to “H 题”">&#8203;</a></h3>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::y87jn9nfvax1iygctcm6::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t, n, x;
    cin &gt;&gt; t;
    while (t &gt; 0) {
        cin &gt;&gt; n &gt;&gt; x;
        t--;
        bool flag = true, flag2 = true;
        while (n &gt; 0) {
            n--;
            int temp;
            cin &gt;&gt; temp;
            if (temp &gt;= x &amp;&amp; flag2) {
                if (flag) {
                    cout &lt;&lt; x &lt;&lt; &quot; &quot; &lt;&lt; temp;
                    flag = false;
                } else {
                    cout &lt;&lt; &quot; &quot; &lt;&lt; x &lt;&lt; &quot; &quot; &lt;&lt; temp;
                }
                flag2 = false;
            } else {
                if (flag) {
                    cout &lt;&lt; temp;
                    flag = false;
                } else {
                    cout &lt;&lt; &quot; &quot; &lt;&lt; temp;
                }
            }
        }
        if (flag2) {
            cout &lt;&lt; &quot; &quot; &lt;&lt; x;
        }
        cout &lt;&lt; endl;
    }
    return 0;
}</code></pre>
</div><h3 id="i-题-3" tabindex="-1">I 题 <a class="header-anchor" href="#i-题-3" aria-label="Permalink to “I 题”">&#8203;</a></h3>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::6wx4lir8kf1d0azhnttp2::--><code>#include &lt;bits/stdc++.h&gt;
typedef long long ll;
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin &gt;&gt; t;
    cin.ignore();
    while (t &gt; 0) {
        t--;
        string s;
        int letter = 0, digit = 0, space = 0, others = 0;

        getline(cin, s);
        for (char c : s) {
            if (isupper(c) or islower(c)) {
                letter++;
            } else if (isdigit(c)) {
                digit++;
            } else if (isspace(c)) {
                space++;
            } else {
                others++;
            }
        }

        printf(&quot;%d %d %d %d\n&quot;, letter, space, digit, others);
    }
    return 0;
}</code></pre>
</div><h3 id="j-题-3" tabindex="-1">J 题 <a class="header-anchor" href="#j-题-3" aria-label="Permalink to “J 题”">&#8203;</a></h3>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::fed8lvn2w75ub9qvufg7cf::--><code>#include &lt;bits/stdc++.h&gt;
typedef long long ll;
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin &gt;&gt; t;
    cin.ignore();
    while (t &gt; 0) {
        t--;
        string s;
        int word = 0;
        bool last_one = false;

        getline(cin, s);
        bool flag = false;
        for (char c : s) {
            if (isspace(c)) {
                last_one = flag;
                flag = false;
            } else {  //  非空
                last_one = flag;
                flag = true;
            }
            if (flag &amp;&amp; last_one == false) {
                word++;
            }
        }

        printf(&quot;%d\n&quot;, word);
    }
    return 0;
}</code></pre>
</div><h3 id="k-题-3" tabindex="-1">K 题 <a class="header-anchor" href="#k-题-3" aria-label="Permalink to “K 题”">&#8203;</a></h3>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::olbpnyd7xh85ytqatqo2a::--><code>#include &lt;bits/stdc++.h&gt;
typedef long long ll;
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin &gt;&gt; t;
    cin.ignore();
    while (t &gt; 0) {
        t--;
        string s;
        int line = 3;
        int upper = 0, lower = 0, digit = 0, space = 0, others = 0;

        while (line &gt; 0) {
            line--;
            getline(cin, s);
            for (char c : s) {
                if (isupper(c)) {
                    upper++;
                } else if (islower(c)) {
                    lower++;
                } else if (isdigit(c)) {
                    digit++;
                } else if (isspace(c)) {
                    space++;
                } else {
                    others++;
                }
            }
        }
        printf(&quot;%d %d %d %d %d\n&quot;, upper, lower, digit, space, others);
    }
    return 0;
}</code></pre>
</div><h3 id="l-题-2" tabindex="-1">L 题 <a class="header-anchor" href="#l-题-2" aria-label="Permalink to “L 题”">&#8203;</a></h3>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::b9mvalugsamwbrh3b08p::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin &gt;&gt; t;
    while (t &gt; 0) {
        t--;
        int n;
        cin &gt;&gt; n;
        int ret = 0;
        while (n &gt;= 5) {
            n /= 5;
            ret += n;
        }
        cout &lt;&lt; ret &lt;&lt; endl;
    }
    return 0;
}</code></pre>
</div><h3 id="m-题-1" tabindex="-1">M 题 <a class="header-anchor" href="#m-题-1" aria-label="Permalink to “M 题”">&#8203;</a></h3>
<p><a href="https://oi-wiki.org/misc/josephus/" target="_blank" rel="noreferrer">约瑟夫问题 - OI Wiki (oi-wiki.org)</a></p>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::o3pqbpk1j20zm2zj5w666::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int josephus(int n, int k) {
    int res = 0;
    for (int i = 2; i &lt;= n; ++i) {
        res = (res + k) % i;
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin &gt;&gt; t;
    while (t &gt; 0) {
        t--;
        int M, K;
        cin &gt;&gt; M &gt;&gt; K;
        // 约瑟夫环公式使用示例
        int i;
        for (i = 1; i &lt;= M; i++) {
            if (josephus(M, i) + 1 == K) {
                cout &lt;&lt; i &lt;&lt; &quot;\n&quot;;
                break;
            };
        }
        if (i &gt; M) {
            cout &lt;&lt; &quot;No Solution!\n&quot;;
        }
    }

    return 0;
}</code></pre>
</div><h3 id="n-题-1" tabindex="-1">N 题 <a class="header-anchor" href="#n-题-1" aria-label="Permalink to “N 题”">&#8203;</a></h3>
<p>一开始 AC 的代码，因为之前的代码 TL 了
Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::fokg1044ptrtrhycru4rd9::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

vector&lt;int&gt; prime = {
    2,   3,   5,   7,   11,  13,  17,  19,  23,  29,  31,  37,  41,  43,
    47,  53,  59,  61,  67,  71,  73,  79,  83,  89,  97,  101, 103, 107,
    109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181,
    191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263,
    269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349,
    353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433,
    439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521,
    523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613,
    617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701,
    709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809,
    811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887,
    907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin &gt;&gt; t;
    while (t &gt; 0) {
        t--;
        ll n;
        cin &gt;&gt; n;
        cout &lt;&lt; n &lt;&lt; &quot;=&quot;;
        bool flag = true;
        for (int p_number : prime) {
            while (n % p_number == 0) {
                n /= p_number;
                if (flag) {
                    cout &lt;&lt; p_number;
                    flag = false;
                } else {
                    cout &lt;&lt; &quot;*&quot; &lt;&lt; p_number;
                }
            }
        }
        int divisor = 1021;
        while (n &gt; 1) {
            while (n % divisor == 0) {
                if (flag) {
                    cout &lt;&lt; divisor;
                    flag = false;
                } else {
                    cout &lt;&lt; &quot;*&quot; &lt;&lt; divisor;
                }
                n /= divisor;
                prime.push_back(divisor);
                divisor = prime.back();
            }
            divisor++;
        }
        cout &lt;&lt; endl;
    }

    return 0;
}</code></pre>
</div><p>事实是我想多了，这样也能 AC。之前 TL 的代码找不到了，也要成未解之谜了。
Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::d8f7srhdl6eebc122dtucd::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin &gt;&gt; t;
    while (t &gt; 0) {
        t--;
        int n;
        cin &gt;&gt; n;
        cout &lt;&lt; n &lt;&lt; &quot;=&quot;;
        bool flag = true;
        int divisor = 2;
        while (n &gt; 1) {
            while (n % divisor == 0) {
                if (flag) {
                    cout &lt;&lt; divisor;
                    flag = false;
                } else {
                    cout &lt;&lt; &quot;*&quot; &lt;&lt; divisor;
                }
                n /= divisor;
                divisor = 2;
            }
            divisor++;
        }
        cout &lt;&lt; endl;
    }
    return 0;
}</code></pre>
</div><h2 id="hrbust-acm-练习-2024-级第-9-周题单-题解分享-a-b" tabindex="-1">Hrbust ACM 练习 2024 级第 9 周题单 题解分享 (A-B) <a class="header-anchor" href="#hrbust-acm-练习-2024-级第-9-周题单-题解分享-a-b" aria-label="Permalink to “Hrbust ACM 练习 2024 级第 9 周题单 题解分享 (A-B)”">&#8203;</a></h2>
<h3 id="前言-5" tabindex="-1">前言 <a class="header-anchor" href="#前言-5" aria-label="Permalink to “前言”">&#8203;</a></h3>
<p>题单链接：<a href="https://vjudge.net/contest/666642" target="_blank" rel="noreferrer">2024 级第九周题单 (DFS &amp;&amp; BFS) - Virtual Judge (vjudge.net)</a></p>
<h3 id="a-题-5" tabindex="-1">A 题 <a class="header-anchor" href="#a-题-5" aria-label="Permalink to “A 题”">&#8203;</a></h3>
<p>原题链接：<a href="https://www.luogu.com.cn/problem/B3622" target="_blank" rel="noreferrer">B3622 枚举子集（递归实现指数型枚举） - 洛谷</a></p>
<p>Python Code</p>
<div class="language-python" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::xlrwqtq7xunetv472pgwr::--><code>arr = [0] * 11

def dfs(site):
    if site == n+1:
        print(&quot;&quot;.join(arr[1:site]))
    if site &lt;= n:
        for j in [&quot;N&quot;,&quot;Y&quot;]:
            arr[site] = j
            dfs(site+1)

n = int(input())
dfs(1)</code></pre>
</div><p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::wjvdrqsf4n8ighv2cdu98b::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int m;
char arr[11],s[2]={&#039;N&#039;,&#039;Y&#039;};

void dfs(int cur) {
    if (cur == m+1) {
        for (int j = 1; j &lt;= cur - 1; ++j) printf(&quot;%c&quot;, arr[j]);
        printf(&quot;\n&quot;);
    }
    if (cur &lt;= m) {
        for (int j = 0; j &lt;= 1; ++j) {
            arr[cur] = s[j];
            dfs(cur + 1);
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    scanf(&quot;%d&quot;, &amp;m);
    dfs(1);
    return 0;
}</code></pre>
</div><h3 id="b-题-5" tabindex="-1">B 题 <a class="header-anchor" href="#b-题-5" aria-label="Permalink to “B 题”">&#8203;</a></h3>
<p>原题链接：<a href="https://www.luogu.com.cn/problem/P1706" target="_blank" rel="noreferrer">P1706 全排列问题 - 洛谷</a>、<a href="https://www.jisuanke.com/problem/T1735" target="_blank" rel="noreferrer">T1735 全排列问题 - 计蒜客</a></p>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::au1tm0l17bdngwt7bth7z::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
#define endl &#039;\n&#039;
#define ios ios::sync_with_stdio(false), cin.tie(nullptr)

const int N = 10;  // 1 based
int n;
int a[N];    // 记录已经使用的数字构成的序列
bool st[N];  // 记录数字是否使用

void dfs(int cur) {
    if (cur == n + 1) {
        for (int i = 1; i &lt;= n; ++i) {
            cout &lt;&lt; std::setw(5) &lt;&lt; a[i];
        }
        cout &lt;&lt; endl;
        return;
    }
    for (int i = 1; i &lt;= n; ++i) {
        if (st[i]) {
            continue;
        }
        a[cur] = i;
        st[i] = true;
        dfs(cur + 1);
        a[cur] = 0;
        st[i] = false;
    }
}
void solve() {
    cin &gt;&gt; n;
    dfs(1);
}

int main() {
    ios;
    int T = 1;
    while (T--) {
        solve();
    }
}</code></pre>
</div><p>Python Code 洛谷能过，计蒜客上最后一个点会超时，可能是 Python 递归效率低导致的</p>
<div class="language-python" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::2fu0iwx1ctqa7kfgk9yoel::--><code>N = 10
a = [0] * N
st = [False] * N


def dfs(cur):
    if cur == n + 1:
        print(&quot;&quot;.join(f&quot;{x:5}&quot; for x in a[1 : n + 1]))

    for i in range(1, n + 1):
        if st[i]:
            continue
        a[cur] = i
        st[i] = True
        dfs(cur + 1)
        a[cur] = 0
        st[i] = False


n = int(input())
dfs(1)</code></pre>
</div><h2 id="hrbust-acm-练习-2024-级第-11-周题单-题解分享-a-b" tabindex="-1">Hrbust ACM 练习 2024 级第 11 周题单 题解分享 (A-B) <a class="header-anchor" href="#hrbust-acm-练习-2024-级第-11-周题单-题解分享-a-b" aria-label="Permalink to “Hrbust ACM 练习 2024 级第 11 周题单 题解分享 (A-B)”">&#8203;</a></h2>
<h3 id="前言-6" tabindex="-1">前言 <a class="header-anchor" href="#前言-6" aria-label="Permalink to “前言”">&#8203;</a></h3>
<p>题单链接：<a href="https://vjudge.net/contest/670756" target="_blank" rel="noreferrer">2024 第 11 周题单 图论基础 - Virtual Judge</a></p>
<h3 id="a-题-6" tabindex="-1">A 题 <a class="header-anchor" href="#a-题-6" aria-label="Permalink to “A 题”">&#8203;</a></h3>
<p>原题链接：<a href="https://www.luogu.com.cn/problem/P5318" target="_blank" rel="noreferrer">P5318【深基 18.例 3】查找文献 - 洛谷</a></p>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::vizhzw1blgbs7xujrzqhh::--><code>#include &lt;bits/stdc++.h&gt;

using namespace std;

int n, m;
vector&lt;bool&gt; vis;
vector&lt;int&gt; max_node;
vector&lt;vector&lt;int&gt;&gt; adj;

void dfs(int u) {
    if (vis[u]) {
        return;
    }

    vis[u] = true;
    cout &lt;&lt; u &lt;&lt; &quot; &quot;;
    for (int i = 0; i &lt; (int)adj[u].size(); ++i) {
        dfs(adj[u][i]);
    }
    return;
}

// 另一种 dfs 实现
// void dfs(int u) {
//     vis[u] = true;
//     cout &lt;&lt; u &lt;&lt; &quot; &quot;;
//     for (int i = 0; i &lt; (int)adj[u].size(); ++i) {
//         int next_node = adj[u][i];
//         if (!vis[next_node]) {
//             dfs(next_node);
//         }
//     }
//     return;
// }

void bfs(int u) {
    queue&lt;int&gt; q;

    q.push(u);
    vis[u] = true;
    cout &lt;&lt; u &lt;&lt; &quot; &quot;;

    while (!q.empty()) {
        u = q.front();
        q.pop();
        for (int i = 0; i &lt; (int)adj[u].size(); ++i) {
            if (!vis[adj[u][i]]) {
                q.push(adj[u][i]);
                vis[adj[u][i]] = true;
                cout &lt;&lt; adj[u][i] &lt;&lt; &quot; &quot;;
            }
        }
    }
}

int main() {
    cin &gt;&gt; n &gt;&gt; m;

    adj.resize(n + 1);

    for (int i = 1; i &lt;= m; ++i) {
        int u, v;
        cin &gt;&gt; u &gt;&gt; v;
        adj[u].push_back(v);
    }

    for (int i = 1; i &lt;= n; i++) {
        sort(adj[i].begin(), adj[i].end());
    }

    vis.assign(n + 1, false);
    for (int i = 1; i &lt;= 2; i++) {
        dfs(i);
    }

    cout &lt;&lt; &#039;\n&#039;;

    vis.assign(n + 1, false);
    bfs(1);

    return 0;
}</code></pre>
</div><h3 id="b-题-6" tabindex="-1">B 题 <a class="header-anchor" href="#b-题-6" aria-label="Permalink to “B 题”">&#8203;</a></h3>
<p>原题链接：<a href="https://www.luogu.com.cn/problem/P3916" target="_blank" rel="noreferrer">P3916 图的遍历 - 洛谷</a></p>
<p>Cpp Code</p>
<div class="language-cpp" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::gna069x1r3u1b17z2fu0en::--><code>#include &lt;bits/stdc++.h&gt;

using namespace std;

int n, m;
vector&lt;bool&gt; vis;
vector&lt;int&gt; max_node;
vector&lt;vector&lt;int&gt;&gt; adj;

void dfs(int u, int start_node) {
    if (vis[u]) {  // 要是访问过，一定是被比较大的 start_node 访问的
        return;
    }
    vis[u] = true;
    max_node[u] = start_node;
    for (int i = 0; i &lt; (int)adj[u].size(); ++i) {
        dfs(adj[u][i], start_node);
    }
    return;
}

int main() {
    cin &gt;&gt; n &gt;&gt; m;

    vis.assign(n + 1, false);
    adj.resize(n + 1);
    max_node.resize(n + 1);

    for (int i = 1; i &lt;= m; ++i) {
        int u, v;
        cin &gt;&gt; u &gt;&gt; v;
        adj[v].push_back(u);
    }

    for (int i = n; i &gt;= 1; i--) {
        dfs(i, i);
    }
    for (int i = 1; i &lt;= n; ++i) {
        cout &lt;&lt; max_node[i] &lt;&lt; &quot; &quot;;
    }

    return 0;
}</code></pre>
</div>]]></content:encoded>
            <author>HowieHz</author>
        </item>
        <item>
            <title><![CDATA[UltraIso 9.7.6.3829 注册码]]></title>
            <link>https://howiehz.top/misc/posts/junk/ultraiso-license-key</link>
            <guid isPermaLink="false">https://howiehz.top/misc/posts/junk/ultraiso-license-key</guid>
            <pubDate>Mon, 29 Jan 2024 02:16:10 GMT</pubDate>
            <description><![CDATA[UltraIso 9.7.6.3829 注册码
::: details 迁移自主站
- 链接：`/archives/1706494568081`
- 分类：`资源图谱 
- 标签：`系统-Window]]></description>
            <content:encoded><![CDATA[<h1 id="ultraiso-9-7-6-3829-注册码" tabindex="-1">UltraIso 9.7.6.3829 注册码 <a class="header-anchor" href="#ultraiso-9-7-6-3829-注册码" aria-label="Permalink to “UltraIso 9.7.6.3829 注册码”">&#8203;</a></h1>
<details class="details custom-block"><summary>迁移自主站</summary>
<ul>
<li>链接：<code>/archives/1706494568081</code></li>
<li>分类：<code>资源图谱 &gt; 工具集 &gt; 工具评测&amp;分享</code></li>
<li>标签：<code>系统-Windows</code> <code>转载重排</code> <code>简体中文</code> <code>2024</code></li>
<li>发布时间 2024-01-29T10:16:10+08:00</li>
<li>访问量：162</li>
<li>评论量：0</li>
<li>移动原因：单纯的复制粘贴，内容有一点点价值。</li>
</ul>
</details>
<p>迁移自本地<code>Obsidian</code>库，原记录于 2023-06-20T22:11:39+08:00。</p>
<p>原帖：<a href="https://www.aihao.cc/thread-86086-1-1.html" target="_blank" rel="noreferrer">原帖</a>由
<a href="https://www.aihao.cc/space-uid-75734.html" target="_blank" rel="noreferrer">xiangnan</a> 发布于 2022-11-23 10:42:23</p>
<p>9.7.6.3829 版官网下载地址：<a href="https://www.ezbsystems.com/ultraiso/" target="_blank" rel="noreferrer">https://www.ezbsystems.com/ultraiso/</a></p>
<h2 id="注册码" tabindex="-1">注册码 <a class="header-anchor" href="#注册码" aria-label="Permalink to “注册码”">&#8203;</a></h2>
<p>两个版本不通用，请注意</p>
<h3 id="中文版" tabindex="-1">中文版 <a class="header-anchor" href="#中文版" aria-label="Permalink to “中文版”">&#8203;</a></h3>
<p>name:</p>
<div class="language-plaintext" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">plaintext</span><pre><!--::markdown-it-async::stmvwpr4y0lwjpm7ccz94::--><code>王涛</code></pre>
</div><p>serial:</p>
<div class="language-plaintext" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">plaintext</span><pre><!--::markdown-it-async::9nlxxyihx36gej1vz5o64l::--><code>7C81-1689-4046-626F</code></pre>
</div><h3 id="多国语言-pe-版" tabindex="-1">多国语言 PE 版 <a class="header-anchor" href="#多国语言-pe-版" aria-label="Permalink to “多国语言 PE 版”">&#8203;</a></h3>
<p>name:</p>
<div class="language-plaintext" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">plaintext</span><pre><!--::markdown-it-async::zaamab3kwyau46hgx86sg::--><code>ru-board</code></pre>
</div><p>serial:</p>
<div class="language-plaintext" dir="ltr"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">plaintext</span><pre><!--::markdown-it-async::awzpuh9b4a6076lwgd2ek5d::--><code>8F5C-FB35-D4BD-943D</code></pre>
</div>]]></content:encoded>
            <author>HowieHz</author>
        </item>
    </channel>
</rss>