<?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/">
    <channel>
        <title>CPUのBLOG</title>
        <link>https://blog.cpunull.me/</link>
        <description>一个NotionNext搭建的博客</description>
        <lastBuildDate>Thu, 19 Mar 2026 02:46:03 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>zh-CN</language>
        <copyright>All rights reserved 2026, CPU</copyright>
        <item>
            <title><![CDATA[大唐杯学习]]></title>
            <link>https://blog.cpunull.me/article/31cb48bf-ea2c-80da-abca-c8c3e6799260</link>
            <guid>https://blog.cpunull.me/article/31cb48bf-ea2c-80da-abca-c8c3e6799260</guid>
            <pubDate>Fri, 13 Feb 2026 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-31cb48bfea2c80daabcac8c3e6799260"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-31cb48bfea2c80bdb16fdb1ef7074612"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A11e5c819-836b-4d61-9d4d-6c658a982903%3Aimage.png?table=block&amp;id=31cb48bf-ea2c-80bd-b16f-db1ef7074612&amp;t=31cb48bf-ea2c-80bd-b16f-db1ef7074612" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-31cb48bfea2c80829e7fddcec9f56e8d"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-31cb48bfea2c8058af65c4fbe07d7b1f"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Ac0ebba99-1c32-4d94-8454-65abe198dca7%3Aimage.png?table=block&amp;id=31cb48bf-ea2c-8058-af65-c4fbe07d7b1f&amp;t=31cb48bf-ea2c-8058-af65-c4fbe07d7b1f" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-31cb48bfea2c80189ecade5d1c17c97a"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-31cb48bfea2c8012b6f3db564b31b8d4"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A53c25115-cc76-48a7-a582-54827b6580d2%3Aimage.png?table=block&amp;id=31cb48bf-ea2c-8012-b6f3-db564b31b8d4&amp;t=31cb48bf-ea2c-8012-b6f3-db564b31b8d4" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-31cb48bfea2c80ce927cf8317404e29a"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-31cb48bfea2c80dc910afe776be77501"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Aace2fa05-a131-489f-a97c-174c10f487f4%3Aimage.png?table=block&amp;id=31cb48bf-ea2c-80dc-910a-fe776be77501&amp;t=31cb48bf-ea2c-80dc-910a-fe776be77501" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-31cb48bfea2c80b3ae12ce9cf9088438"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-31cb48bfea2c805fb759eac14e6beaf9"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A5c129d95-fd8f-4519-ac22-f926f577b713%3Aimage.png?table=block&amp;id=31cb48bf-ea2c-805f-b759-eac14e6beaf9&amp;t=31cb48bf-ea2c-805f-b759-eac14e6beaf9" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-31cb48bfea2c80e5b25de14545a04949"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-31cb48bfea2c800eb888c52a74525a98"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Ab91d9b47-c290-458e-bd68-6eb563b47cb2%3Aimage.png?table=block&amp;id=31cb48bf-ea2c-800e-b888-c52a74525a98&amp;t=31cb48bf-ea2c-800e-b888-c52a74525a98" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-31db48bfea2c808183d1c584d96929e3"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-31db48bfea2c8084b016fe979e6abb53"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Abc5463b7-5f16-48ba-a9d2-3bcc55c71d43%3Aimage.png?table=block&amp;id=31db48bf-ea2c-8084-b016-fe979e6abb53&amp;t=31db48bf-ea2c-8084-b016-fe979e6abb53" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-31db48bfea2c802482edf69d05341481"> </div><div class="notion-text notion-block-31db48bfea2c80e0bde7d149e7e2876d">主要采用Option3系列的方式，而其中Option3x是主流，Option7系列的成本比较高</div><hr class="notion-hr notion-block-c62cedf2a04d4679a9480a5f4c378051"/><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-544eb302c1714a07b479c624472476bf" data-id="544eb302c1714a07b479c624472476bf"><span><div id="544eb302c1714a07b479c624472476bf" class="notion-header-anchor"></div><a class="notion-hash-link" href="#544eb302c1714a07b479c624472476bf" title="5G NR随机接入（Random Access）题目解析"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">5G NR随机接入（Random Access）题目解析</span></span></h3><div class="notion-text notion-block-11ae003e09ff4882b76063c59fb71428"><b>题目：5G NR系统中，关于随机接入的目的描述错误的是（ ）</b></div><div class="notion-text notion-block-fd32a46ca5704047a088e91992fed616">A. 实现UE和gNB之间的<b>上行同步</b></div><div class="notion-text notion-block-b00e678b0f454911a79ff9bfa4fb260d">B. 获取MSG3的资源</div><div class="notion-text notion-block-3571858855c64e72b64b7f689122057c">C. 获取C-RNTI，基站识别UE的标识</div><div class="notion-text notion-block-9d7d30de0f5240c6a253bba5520907ae">D. 实现UE和gNB之间的<b>下行同步</b></div><div class="notion-text notion-block-cfd4824f92df4c32899cf3a3805315f6"><b>答案：D</b></div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-b0d83e5f85cf49daae8415718aa1704d" data-id="b0d83e5f85cf49daae8415718aa1704d"><span><div id="b0d83e5f85cf49daae8415718aa1704d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#b0d83e5f85cf49daae8415718aa1704d" title="解析"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">解析</span></span></h4><div class="notion-text notion-block-fea22206f371454898565c9172728d26">在5G NR随机接入（Random Access, RA）过程中，主要目的有：</div><div class="notion-text notion-block-fdf6b09a007f47b498a62664ac27d505"><b>1. 实现上行时间同步</b></div><div class="notion-text notion-block-c09d648c053b4df895f2d3f558c31cfe">UE刚接入小区时，上行发送时间不对齐，需要通过随机接入获得 <b>Timing Advance</b>。→ 所以 <b>A正确</b></div><div class="notion-text notion-block-f2de14bdb0f44abb9d572c6431d34902"><b>2. 为MSG3分配资源</b></div><div class="notion-text notion-block-77fa695e40b8483ab0f9035d1fa9f30e">随机接入流程：</div><ul class="notion-list notion-list-disc notion-block-cffa6592d4184f5d841a49c491dba9ab"><li>MSG1：UE发送PRACH前导</li></ul><ul class="notion-list notion-list-disc notion-block-1a369abd3f274402bbc37a1d2046f24f"><li>MSG2：gNB发送RAR（里面包含 <b>MSG3资源分配 + TA + 临时RNTI</b>）</li></ul><ul class="notion-list notion-list-disc notion-block-27f32140179e4ae5b6cb77379f0758c3"><li>MSG3：UE发送RRC请求</li></ul><ul class="notion-list notion-list-disc notion-block-80e3bb908e2a4128979269db10005222"><li>MSG4：竞争解决</li></ul><div class="notion-text notion-block-70267be572ad49299142af9e292ae673">→ MSG2里会给MSG3资源 → <b>B正确</b></div><div class="notion-text notion-block-186c5ef13dad40c49ba1f3e203f2209f"><b>3. 获得C-RNTI标识UE</b></div><div class="notion-text notion-block-a6135bd0bba64021bc7a38ff2372470c">随机接入完成后，UE会获得 <b>C-RNTI</b>，作为之后通信的标识。→ <b>C正确</b></div><div class="notion-text notion-block-3ba06f26d4eb4a0f9d582f0df20fefc2"><b>4. 下行同步不是随机接入实现的</b></div><div class="notion-text notion-block-4d6a7d81340f4b1baaf83164b105fc8f">UE在接入前就通过 <b>SSB（同步信号块）</b> 完成：</div><ul class="notion-list notion-list-disc notion-block-c157f0fc01b049fdae9986d2a766ca68"><li>PSS</li></ul><ul class="notion-list notion-list-disc notion-block-8e0cfc2215f14ebda4a13cc723f2ca4f"><li>SSS</li></ul><ul class="notion-list notion-list-disc notion-block-69f9f6df5bb548219b04ca1bbc833aa7"><li>PBCH</li></ul><div class="notion-text notion-block-898692cf075b4513a947c09fbb33cae9">来实现下行同步和小区搜索。→ 所以 <b>D是错误描述</b></div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-0b4fd06a9af64ea3ad8887ca5538c5e3" data-id="0b4fd06a9af64ea3ad8887ca5538c5e3"><span><div id="0b4fd06a9af64ea3ad8887ca5538c5e3" class="notion-header-anchor"></div><a class="notion-hash-link" href="#0b4fd06a9af64ea3ad8887ca5538c5e3" title="总结"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">总结</span></span></h4><table class="notion-simple-table notion-block-153bc54473a645d3b3e69b9e47bdf083"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-3a047f985c934745834cce3c9c6a9e8b"><td class="" style="width:120px"><div class="notion-simple-table-cell">选项</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">结论</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">原因</div></td></tr><tr class="notion-simple-table-row notion-block-db15222040a84f279f1fe816feeb3a97"><td class="" style="width:120px"><div class="notion-simple-table-cell">A</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">✔</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">RA实现上行同步</div></td></tr><tr class="notion-simple-table-row notion-block-9cc04fc7abb34a0793be21605ff0c864"><td class="" style="width:120px"><div class="notion-simple-table-cell">B</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">✔</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">RAR中分配MSG3资源</div></td></tr><tr class="notion-simple-table-row notion-block-48fcbb7420114d139b7e3804bf68d198"><td class="" style="width:120px"><div class="notion-simple-table-cell">C</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">✔</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">完成后获得C-RNTI</div></td></tr><tr class="notion-simple-table-row notion-block-aee37fdca7d34cdc9763870bf792db04"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>D</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">✘</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">下行同步由SSB完成</div></td></tr></tbody></table><div class="notion-text notion-block-d693f12b3b244aaf80a0865e31c43c21"><b>答案：D</b></div><hr class="notion-hr notion-block-4d91a0ba656b494b86dc4ad95d401a74"/><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-2f0f2aa3bbbd4fc1a2983793fa5f7611" data-id="2f0f2aa3bbbd4fc1a2983793fa5f7611"><span><div id="2f0f2aa3bbbd4fc1a2983793fa5f7611" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2f0f2aa3bbbd4fc1a2983793fa5f7611" title="mDAS系统（微型分布式天线系统）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">mDAS系统（微型分布式天线系统）</span></span></h3><div class="notion-text notion-block-dafe21d2138a421aba143a093cedf9a8"><b>mDAS = mini Distributed Antenna System</b></div><div class="notion-text notion-block-c8ea5008d14a45afaa6efd804e85184c">用于<b>室内覆盖或小场景覆盖</b>，如商场、地铁、办公楼、体育馆、酒店等。</div><div class="notion-text notion-block-a7ee486c98574cfbb17bf28279db5741">作用：<b>把基站信号分布到很多小天线，实现均匀覆盖。</b></div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-04b3f1957242400987ca5e263d441c97" data-id="04b3f1957242400987ca5e263d441c97"><span><div id="04b3f1957242400987ca5e263d441c97" class="notion-header-anchor"></div><a class="notion-hash-link" href="#04b3f1957242400987ca5e263d441c97" title="mDAS系统组成：MU + EU + RU"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">mDAS系统组成：MU + EU + RU</span></span></h4><div class="notion-text notion-block-9621322d5cb94ab19ee37d7555dac9a9"><b>1. MU（Main Unit）主单元 = 系统大脑</b></div><ul class="notion-list notion-list-disc notion-block-3c1648b448c9453f9baf2f238d5aefb6"><li>连接运营商<b>基站BBU</b></li></ul><ul class="notion-list notion-list-disc notion-block-29d3773a06384268a8602352d8c804ab"><li>进行<b>信号处理与管理</b></li></ul><ul class="notion-list notion-list-disc notion-block-d1f346db7ae044519ef641474215f23b"><li>控制整个mDAS系统</li></ul><div class="notion-text notion-block-a6d9550a950b43cfb7096a46745de0cd"><b>2. EU（Extension Unit）扩展单元 = 信号分配器</b></div><ul class="notion-list notion-list-disc notion-block-2967935f6c0d4df7bde4219eb223b058"><li>扩展系统容量</li></ul><ul class="notion-list notion-list-disc notion-block-c166bc13f9704e7eb71f5b2daa17cfdf"><li>将MU信号<b>分配给多个RU</b></li></ul><ul class="notion-list notion-list-disc notion-block-79684511d8ff49dfbac64f33ef99d5e6"><li>扩大覆盖范围</li></ul><div class="notion-text notion-block-e1fda32ce73243cbb53c41232a708930"><b>3. RU（Radio Unit）射频单元 = 发射设备</b></div><ul class="notion-list notion-list-disc notion-block-8caf4dddc1554ba8bd08886931bd7c9b"><li>把信号变成<b>无线电信号</b></li></ul><ul class="notion-list notion-list-disc notion-block-b504724f1e914aa78df5e70826a6564a"><li>连接天线</li></ul><ul class="notion-list notion-list-disc notion-block-0e7246e152004e25831c5b89e73094d2"><li>实际进行<b>无线覆盖</b></li></ul><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-febd35a460f3464c833e53c8db530d21" data-id="febd35a460f3464c833e53c8db530d21"><span><div id="febd35a460f3464c833e53c8db530d21" class="notion-header-anchor"></div><a class="notion-hash-link" href="#febd35a460f3464c833e53c8db530d21" title="mDAS整体结构"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">mDAS整体结构</span></span></h4><div class="notion-text notion-block-bea5f6685cc54c358fb933160dad2842"><code class="notion-inline-code">基站BBU → MU（主单元） → EU（扩展单元） → RU（射频单元） → 天线 → 手机用户</code></div><div class="notion-text notion-block-be8a5fd486474e1f9d648f7237d3be05">一句话总结：<b>MU控制 → EU扩展 → RU发射</b></div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-fb1be855f36540e0a65676c72e3a8680" data-id="fb1be855f36540e0a65676c72e3a8680"><span><div id="fb1be855f36540e0a65676c72e3a8680" class="notion-header-anchor"></div><a class="notion-hash-link" href="#fb1be855f36540e0a65676c72e3a8680" title="考试记忆口诀"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">考试记忆口诀</span></span></h4><table class="notion-simple-table notion-block-200c3b1439f043d29cc0c6eb53c29d97"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-e6040489e2c74987a3b3127d7f59cc19"><td class="" style="width:120px"><div class="notion-simple-table-cell">单元</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">英文</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">功能</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">记忆</div></td></tr><tr class="notion-simple-table-row notion-block-c1ecfce93c5c4442a7c0bd9c10c9669d"><td class="" style="width:120px"><div class="notion-simple-table-cell">MU</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Main Unit</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">主控/信号处理</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">大脑</div></td></tr><tr class="notion-simple-table-row notion-block-eb29fdd4eb6044fe9487487c279ab14e"><td class="" style="width:120px"><div class="notion-simple-table-cell">EU</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Extension Unit</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">扩展/分发</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">分配器</div></td></tr><tr class="notion-simple-table-row notion-block-701de21dfd3447c98a4ba5c6661cf138"><td class="" style="width:120px"><div class="notion-simple-table-cell">RU</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Radio Unit</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">射频/发射</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">发射器</div></td></tr></tbody></table><hr class="notion-hr notion-block-ace1bf927e334e3daf49b46876527c46"/><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-3c22fdf03c5b42718bf1aca4bfdc5db2" data-id="3c22fdf03c5b42718bf1aca4bfdc5db2"><span><div id="3c22fdf03c5b42718bf1aca4bfdc5db2" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3c22fdf03c5b42718bf1aca4bfdc5db2" title="SL site（小型站点设备）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">SL site（小型站点设备）</span></span></h3><div class="notion-text notion-block-04091891b3264e99a0f9e15c810abf1e"><b>SL = Small + Simple + Low</b></div><table class="notion-simple-table notion-block-735008dd6f6e41cc9b02396ae1e869db"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-196344f61c61437c948cbe75bb64f35b"><td class="" style="width:120px"><div class="notion-simple-table-cell">单词</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">含义</div></td></tr><tr class="notion-simple-table-row notion-block-53451df0df874106a16f6e81b55c86ca"><td class="" style="width:120px"><div class="notion-simple-table-cell">Small</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">小型化</div></td></tr><tr class="notion-simple-table-row notion-block-7dbc795f506743709839d66102ed9a5e"><td class="" style="width:120px"><div class="notion-simple-table-cell">Simple</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">简单</div></td></tr><tr class="notion-simple-table-row notion-block-cb8daded6a07422eb6a0b945ad9998f1"><td class="" style="width:120px"><div class="notion-simple-table-cell">Low</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">低功耗</div></td></tr></tbody></table><div class="notion-text notion-block-921e1d197c724707a88685e8a6fca575"><b>SL site = 小型、简单、低功耗的站点设备</b></div><div class="notion-text notion-block-4f91336a1e894c06a0f6d9192ad9e606">特点：</div><ul class="notion-list notion-list-disc notion-block-38411426fec34f91bb4de12d413d6823"><li>设备体积小</li></ul><ul class="notion-list notion-list-disc notion-block-046045face30482c982b1c67297b9adf"><li>功耗低</li></ul><ul class="notion-list notion-list-disc notion-block-fc48446fe0d84038b6e4e57381335edb"><li>部署简单</li></ul><ul class="notion-list notion-list-disc notion-block-feaa61d8966740a485eb78e3574748d7"><li>成本低</li></ul><div class="notion-text notion-block-4f17a83a5aa3400db145f4435c89e2e5">通常用于小型室内覆盖、微基站、小场景部署。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-31db48bfea2c80b3afe8e30d8450c7ac"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A01a967dc-911b-4901-a827-ffff79ac72dd%3Aimage.png?table=block&amp;id=31db48bf-ea2c-80b3-afe8-e30d8450c7ac&amp;t=31db48bf-ea2c-80b3-afe8-e30d8450c7ac" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-31db48bfea2c807aaa54f57072252257"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-31db48bfea2c80a8bb91c8740fd11371"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A085f02f7-f269-43f9-be5c-72be1dbd4d17%3Aimage.png?table=block&amp;id=31db48bf-ea2c-80a8-bb91-c8740fd11371&amp;t=31db48bf-ea2c-80a8-bb91-c8740fd11371" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-31db48bfea2c8015b0b7dabef091be5c"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-31db48bfea2c80b0b803fd62e66a5458"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A466b4290-8ff4-4c00-a48c-2f6160878274%3Aimage.png?table=block&amp;id=31db48bf-ea2c-80b0-b803-fd62e66a5458&amp;t=31db48bf-ea2c-80b0-b803-fd62e66a5458" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-31db48bfea2c801eaed4e2a5b7fe3361"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-31db48bfea2c80f6bf89fe36c20ae89b"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A062a782b-cf69-48de-89b7-7b23ea4f07b1%3Aimage.png?table=block&amp;id=31db48bf-ea2c-80f6-bf89-fe36c20ae89b&amp;t=31db48bf-ea2c-80f6-bf89-fe36c20ae89b" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-31db48bfea2c800fba83f6b52878df2c"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-31db48bfea2c80fc9ceed27fdcd97f4a"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A95ab87d2-e03d-46c1-b6ec-c96cb3590e45%3Aimage.png?table=block&amp;id=31db48bf-ea2c-80fc-9cee-d27fdcd97f4a&amp;t=31db48bf-ea2c-80fc-9cee-d27fdcd97f4a" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-31db48bfea2c804ab57ff77d62a063d4"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-31db48bfea2c80bab638cb9621b3aaec"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A6bf5d2e3-e0e6-4073-9bfa-fa00c76269da%3Aimage.png?table=block&amp;id=31db48bf-ea2c-80ba-b638-cb9621b3aaec&amp;t=31db48bf-ea2c-80ba-b638-cb9621b3aaec" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-31db48bfea2c80b489c5f670b2ab334e"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-31db48bfea2c807497ddf58b5d009205"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Aa25fca8c-94a9-4eca-984c-320fc72b3bd9%3Aimage.png?table=block&amp;id=31db48bf-ea2c-8074-97dd-f58b5d009205&amp;t=31db48bf-ea2c-8074-97dd-f58b5d009205" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-31db48bfea2c805d9a45c791385e25f1"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-31db48bfea2c80e19a0ff620bd7a4d58"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A42800bd6-d56a-465b-b70e-426a64e4e0f5%3Aimage.png?table=block&amp;id=31db48bf-ea2c-80e1-9a0f-f620bd7a4d58&amp;t=31db48bf-ea2c-80e1-9a0f-f620bd7a4d58" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-31db48bfea2c80f484d2ef8981cc9174"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-31db48bfea2c8015a8abd9ad43f8c1fb"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A1516f9e5-79f6-4cce-94b6-19a5b0d5da6c%3Aimage.png?table=block&amp;id=31db48bf-ea2c-8015-a8ab-d9ad43f8c1fb&amp;t=31db48bf-ea2c-8015-a8ab-d9ad43f8c1fb" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-31db48bfea2c80128d4dcf7ff64af5a4"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-31db48bfea2c8042867ef5aacf108012"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A4206e0e8-b741-4ff3-8d41-9877fd5acde8%3Aimage.png?table=block&amp;id=31db48bf-ea2c-8042-867e-f5aacf108012&amp;t=31db48bf-ea2c-8042-867e-f5aacf108012" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-31db48bfea2c80609f1ad45809db3806"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-31db48bfea2c805ab9f1e6ff8e03e3f5"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Aa966ce72-5a6a-4f9a-85ce-91608f59c8a6%3Aimage.png?table=block&amp;id=31db48bf-ea2c-805a-b9f1-e6ff8e03e3f5&amp;t=31db48bf-ea2c-805a-b9f1-e6ff8e03e3f5" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-31db48bfea2c80d08bdbedcdb25986cb"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-31db48bfea2c802abbf6ead7f505b1c3"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Af49dc11a-d46d-48d7-ae0c-978d3553a55d%3Aimage.png?table=block&amp;id=31db48bf-ea2c-802a-bbf6-ead7f505b1c3&amp;t=31db48bf-ea2c-802a-bbf6-ead7f505b1c3" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-31eb48bfea2c80c39c4dda3c41c39826"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A2217d840-8d0a-479f-aa60-5d9e288cb21b%3A1000004161.jpg?table=block&amp;id=31eb48bf-ea2c-80c3-9c4d-da3c41c39826&amp;t=31eb48bf-ea2c-80c3-9c4d-da3c41c39826" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-322b48bfea2c80808824dbace8427cad"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-322b48bfea2c8012af02dfbca2248953"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Afff76315-fcec-44da-b65a-4b2f46b68ede%3Aimage.png?table=block&amp;id=322b48bf-ea2c-8012-af02-dfbca2248953&amp;t=322b48bf-ea2c-8012-af02-dfbca2248953" alt="notion image" loading="lazy" decoding="async"/></div></figure><details class="notion-toggle notion-block-322b48bfea2c80e381f7cfdb1dd98e5d"><summary></summary><div><div class="notion-text notion-block-322b48bfea2c80668e9eda0bf5bd6b2d">好的，我来帮你讲解这张图，内容是 <b>5G NG-RAN（Next Generation Radio Access Network）总体架构</b>。我会分几个部分说明图和文字内容。</div><hr class="notion-hr notion-block-322b48bfea2c80a0be6fcb9c70a92c16"/><h4 class="notion-h notion-h3 notion-block-322b48bfea2c80e78711f440f3ce1636" data-id="322b48bfea2c80e78711f440f3ce1636"><span><div id="322b48bfea2c80e78711f440f3ce1636" class="notion-header-anchor"></div><a class="notion-hash-link" href="#322b48bfea2c80e78711f440f3ce1636" title="1️⃣ NG-RAN 的组成"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">1️⃣ NG-RAN 的组成</span></span></h4><div class="notion-text notion-block-322b48bfea2c8087bccbe65581cc5fb6">NG-RAN 是 5G 接入网（RAN），它主要包含两类基站：</div><ul class="notion-list notion-list-disc notion-block-322b48bfea2c8087b01ed0cb36329294"><li><b>gNB</b>：5G NR 基站，直接为 5G 用户提供无线接入。</li></ul><ul class="notion-list notion-list-disc notion-block-322b48bfea2c80099124f9ae015bdb8a"><li><b>ng-eNB</b>：5G 演进版的 LTE 基站（向 5G 核心网兼容），使用 <b>E-UTRA</b> 协议为用户提供服务。</li></ul><div class="notion-text notion-block-322b48bfea2c80089c82d4b6667c9c85">图中你圈出的 <b>gNB</b> 和 <b>ng-eNB</b> 就对应这里。</div><hr class="notion-hr notion-block-322b48bfea2c808ea239df6bdbec1294"/><h4 class="notion-h notion-h3 notion-block-322b48bfea2c8022910ffa67ba6128c7" data-id="322b48bfea2c8022910ffa67ba6128c7"><span><div id="322b48bfea2c8022910ffa67ba6128c7" class="notion-header-anchor"></div><a class="notion-hash-link" href="#322b48bfea2c8022910ffa67ba6128c7" title="2️⃣ 核心网（5GC）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2️⃣ 核心网（5GC）</span></span></h4><div class="notion-text notion-block-322b48bfea2c80c1aae4fa0417956713">5G 核心网主要有两个功能实体：</div><ul class="notion-list notion-list-disc notion-block-322b48bfea2c80a9af47e4cec724050d"><li><b>AMF（Access and Mobility Management Function）</b>：控制面（管理信令、移动性、接入）。</li></ul><ul class="notion-list notion-list-disc notion-block-322b48bfea2c8032a9f9c6e80448b404"><li><b>UPF（User Plane Function）</b>：用户面（处理数据流）。</li></ul><div class="notion-text notion-block-322b48bfea2c80f5826cefa55a8a8df6">图中顶部圈出的 <b>AMF/UPF</b> 就表示这两个功能可能在一个物理设备上实现（逻辑上可以分开）。</div><hr class="notion-hr notion-block-322b48bfea2c80c1a21ae5d38fa0ac35"/><h4 class="notion-h notion-h3 notion-block-322b48bfea2c80288d0be1e3d68cfa27" data-id="322b48bfea2c80288d0be1e3d68cfa27"><span><div id="322b48bfea2c80288d0be1e3d68cfa27" class="notion-header-anchor"></div><a class="notion-hash-link" href="#322b48bfea2c80288d0be1e3d68cfa27" title="3️⃣ 网络接口"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">3️⃣ 网络接口</span></span></h4><div class="notion-text notion-block-322b48bfea2c8019bb72fa17dd1a16e7">5G RAN 与核心网、基站之间的接口：</div><ul class="notion-list notion-list-disc notion-block-322b48bfea2c80bc98f0de4048ceecc8"><li><b>Xn 接口</b>：</li><ul class="notion-list notion-list-disc notion-block-322b48bfea2c80bc98f0de4048ceecc8"><li>gNB ↔ gNB 或 ng-eNB ↔ ng-eNB 之间使用</li><li>用于数据和信令交换（图中蓝色线标注 Xn）</li></ul></ul><ul class="notion-list notion-list-disc notion-block-322b48bfea2c80cda2a2f95441567015"><li><b>NG 接口</b>：</li><ul class="notion-list notion-list-disc notion-block-322b48bfea2c80cda2a2f95441567015"><li>NG2 接口：gNB / ng-eNB ↔ AMF（控制面）</li><li>NG3 接口：gNB / ng-eNB ↔ UPF（用户面）</li><li>图中绿色线标注 NG</li></ul></ul><hr class="notion-hr notion-block-322b48bfea2c808ea3b2d7308f30d003"/><h4 class="notion-h notion-h3 notion-block-322b48bfea2c80dd8b40fb97a81c4a00" data-id="322b48bfea2c80dd8b40fb97a81c4a00"><span><div id="322b48bfea2c80dd8b40fb97a81c4a00" class="notion-header-anchor"></div><a class="notion-hash-link" href="#322b48bfea2c80dd8b40fb97a81c4a00" title="4️⃣ NG-RAN 节点类型"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">4️⃣ NG-RAN 节点类型</span></span></h4><ul class="notion-list notion-list-disc notion-block-322b48bfea2c8065a593f02f5cfaaee7"><li><b>gNB</b>：与 UE（用户设备）使用 <b>NR 协议</b> 控制面和用户面。</li></ul><ul class="notion-list notion-list-disc notion-block-322b48bfea2c80aa8efbfa7c83a57644"><li><b>ng-eNB</b>：与 UE 使用 <b>E-UTRA 协议</b> 控制面和用户面。</li></ul><div class="notion-text notion-block-322b48bfea2c80fbba70c28c1e9e889a">所以在图里：</div><ul class="notion-list notion-list-disc notion-block-322b48bfea2c805191d3dd5b4dafeb66"><li>你标注的 <b>X1、X2</b> 是不同的接口标记，X2 指向基站间通信（Xn 接口的一种）。</li></ul><ul class="notion-list notion-list-disc notion-block-322b48bfea2c803886a4f81c518caf89"><li>S1 是 LTE 时代的接口名字，这里画出来是为了和 5G 核心网 NG 接口对比。</li></ul><hr class="notion-hr notion-block-322b48bfea2c80d8bc4bf903ff57c11a"/><h4 class="notion-h notion-h3 notion-block-322b48bfea2c801cbbf3c32535495611" data-id="322b48bfea2c801cbbf3c32535495611"><span><div id="322b48bfea2c801cbbf3c32535495611" class="notion-header-anchor"></div><a class="notion-hash-link" href="#322b48bfea2c801cbbf3c32535495611" title="5️⃣ 图的整体理解"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">5️⃣ 图的整体理解</span></span></h4><ul class="notion-list notion-list-disc notion-block-322b48bfea2c804f9cfcd12be7fdd313"><li>左侧和右侧的 <b>gNB</b> / <b>ng-eNB</b> 是接入网部分（NG-RAN）。</li></ul><ul class="notion-list notion-list-disc notion-block-322b48bfea2c80b6920bd0113b956a4b"><li>顶部 <b>AMF/UPF</b> 是核心网部分（5GC）。</li></ul><ul class="notion-list notion-list-disc notion-block-322b48bfea2c80c694b3f2161a4474b7"><li>蓝色线 <b>Xn</b> 表示基站间的数据/信令连接。</li></ul><ul class="notion-list notion-list-disc notion-block-322b48bfea2c80308e03cdeabe826369"><li>绿色线 <b>NG</b> 表示基站与核心网的连接。</li></ul><ul class="notion-list notion-list-disc notion-block-322b48bfea2c8083913ce74f5124a572"><li>NG-RAN 支持混合部署：NR 基站 + 演进 LTE 基站。</li></ul><hr class="notion-hr notion-block-322b48bfea2c8091b71fe59614f3cc55"/><div class="notion-text notion-block-322b48bfea2c80ac9579c69511fa4f5c">如果你愿意，我可以画一张 <b>更清晰的中文标注 NG-RAN 架构图</b>，把接口和节点类型都标出来，看一眼就能理解。</div><div class="notion-text notion-block-322b48bfea2c80af9c58fede71c71591">你希望我画吗？</div></div></details><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-322b48bfea2c802f9404d40b51fd22bb"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A8f9cd753-8484-407b-b3a1-aea1a7d38348%3Aimage.png?table=block&amp;id=322b48bf-ea2c-802f-9404-d40b51fd22bb&amp;t=322b48bf-ea2c-802f-9404-d40b51fd22bb" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-322b48bfea2c804eba5fe56e62441933"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:549.9874877929688px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A95fa5207-697b-4167-a479-88660438d25c%3Aimage.png?table=block&amp;id=322b48bf-ea2c-804e-ba5f-e56e62441933&amp;t=322b48bf-ea2c-804e-ba5f-e56e62441933" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-322b48bfea2c808b966bf01ca329ab60"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-322b48bfea2c80dcad6be44c12e81cd1"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Af327c88f-97c0-42b0-8cf5-c824763ddb82%3Aimage.png?table=block&amp;id=322b48bf-ea2c-80dc-ad6b-e44c12e81cd1&amp;t=322b48bf-ea2c-80dc-ad6b-e44c12e81cd1" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-322b48bfea2c80a19684c02d34e0ec0f"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A09bcb032-00d2-4030-bf49-bfd44ce04cbf%3Aimage.png?table=block&amp;id=322b48bf-ea2c-80a1-9684-c02d34e0ec0f&amp;t=322b48bf-ea2c-80a1-9684-c02d34e0ec0f" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-322b48bfea2c8070b976e6d79eb63d53"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A80c1a69a-af0e-4e92-a5dc-5318c308b73d%3Aimage.png?table=block&amp;id=322b48bf-ea2c-8070-b976-e6d79eb63d53&amp;t=322b48bf-ea2c-8070-b976-e6d79eb63d53" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-322b48bfea2c80e087c4d013bd412ccc"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-322b48bfea2c80b59bb4c928253a8818"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A4a7e8e5e-b4e7-4338-b875-3dcb0446f1ca%3Aimage.png?table=block&amp;id=322b48bf-ea2c-80b5-9bb4-c928253a8818&amp;t=322b48bf-ea2c-80b5-9bb4-c928253a8818" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-322b48bfea2c802db48bc0a5f69c9ce1"> </div><div class="notion-blank notion-block-322b48bfea2c8098bfc0c90d5926167e"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-322b48bfea2c8067b6a2f89514efc6af"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Ab67938fc-5354-4b70-93a8-cabe90863559%3Aimage.png?table=block&amp;id=322b48bf-ea2c-8067-b6a2-f89514efc6af&amp;t=322b48bf-ea2c-8067-b6a2-f89514efc6af" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-322b48bfea2c809f99fbdbd79aece1ca"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-322b48bfea2c8069ba76d9aa6ea80888"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Afd48a57e-3bcd-4c2d-8089-672ed8f9ef7d%3Aimage.png?table=block&amp;id=322b48bf-ea2c-8069-ba76-d9aa6ea80888&amp;t=322b48bf-ea2c-8069-ba76-d9aa6ea80888" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-322b48bfea2c806bbefdc2c597f1aef7">人流密度大，又比较空旷的商用场景</div><div class="notion-blank notion-block-322b48bfea2c80a59deccf2b6dc35a8d"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-322b48bfea2c8065be24e9f2b8ae5d6f"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Aaa53f8c4-25fd-450f-a669-d88755aff668%3Aimage.png?table=block&amp;id=322b48bf-ea2c-8065-be24-e9f2b8ae5d6f&amp;t=322b48bf-ea2c-8065-be24-e9f2b8ae5d6f" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-322b48bfea2c806f8990dfa287321a02"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-322b48bfea2c80cc874edd14a302f46c"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A2fa73b1c-b94c-47ef-9278-17335bc93799%3Aimage.png?table=block&amp;id=322b48bf-ea2c-80cc-874e-dd14a302f46c&amp;t=322b48bf-ea2c-80cc-874e-dd14a302f46c" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-322b48bfea2c80b5aba3c7e9c546a653">4G主要采用的是64QAM,如果实际环境达不到，就会到16QAM</div><div class="notion-text notion-block-322b48bfea2c80f98dd9d3435b144793">5G主要采用的是256QAM,就会降阶，到64QAM或者16QAM，一般来说，信号不好就会造成这样的降阶</div><div class="notion-blank notion-block-322b48bfea2c80478b75f6e9bdaf70a7"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-322b48bfea2c8031a36ff5311af7ef4f"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A819a386b-82bf-49f4-8e1e-3a5c727eaa7b%3Aimage.png?table=block&amp;id=322b48bf-ea2c-8031-a36f-f5311af7ef4f&amp;t=322b48bf-ea2c-8031-a36f-f5311af7ef4f" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-322b48bfea2c80c79068ec89aba37ad5"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-322b48bfea2c805c889ae7b12904ee3e"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A8624d1f2-7995-44bb-9ab3-b3152f267f6d%3Aimage.png?table=block&amp;id=322b48bf-ea2c-805c-889a-e7b12904ee3e&amp;t=322b48bf-ea2c-805c-889a-e7b12904ee3e" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-322b48bfea2c80c7b28ae099a5ccfd7b"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-322b48bfea2c80df8a1ac42a9e499d1b"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Ad0ea96c9-95b2-4635-ad15-a8343043d5ed%3Aimage.png?table=block&amp;id=322b48bf-ea2c-80df-8a1a-c42a9e499d1b&amp;t=322b48bf-ea2c-80df-8a1a-c42a9e499d1b" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-322b48bfea2c8021b668f6e941a5990b"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-322b48bfea2c80f0939ee6e8bacdfa3f"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A6b7557f7-95df-444b-b1e9-8f1ca96c86a8%3Aimage.png?table=block&amp;id=322b48bf-ea2c-80f0-939e-e6e8bacdfa3f&amp;t=322b48bf-ea2c-80f0-939e-e6e8bacdfa3f" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-322b48bfea2c80459555e30c2c85ebb1"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-322b48bfea2c801093d3f44076072257"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Acd9ca703-5ee3-45ac-a5b1-a8c360c90195%3Aimage.png?table=block&amp;id=322b48bf-ea2c-8010-93d3-f44076072257&amp;t=322b48bf-ea2c-8010-93d3-f44076072257" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-323b48bfea2c802cb15dd5d743c2c185"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-323b48bfea2c80bea660ef56490704d9"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A3088f7b7-26c4-4f68-ab29-0ba5592df4d3%3Aimage.png?table=block&amp;id=323b48bf-ea2c-80be-a660-ef56490704d9&amp;t=323b48bf-ea2c-80be-a660-ef56490704d9" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-322b48bfea2c80889f09c94c327b40ab"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-323b48bfea2c8044ba7ce10d7506b66a"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A86540f5e-dfa1-480b-af3b-da94f60e8493%3Aimage.png?table=block&amp;id=323b48bf-ea2c-8044-ba7c-e10d7506b66a&amp;t=323b48bf-ea2c-8044-ba7c-e10d7506b66a" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-323b48bfea2c8097bc3bc3e435096cb7"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-323b48bfea2c806a9a66fbb90f166179"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A3dc30a84-f228-4178-b73a-ecd6267cbfc4%3Aimage.png?table=block&amp;id=323b48bf-ea2c-806a-9a66-fbb90f166179&amp;t=323b48bf-ea2c-806a-9a66-fbb90f166179" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-323b48bfea2c80079c83f0369509dccb"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-323b48bfea2c8000b8bbea512840d3c5"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A42477c5b-42e1-44ef-8b1c-04a3b7fe2f68%3Aimage.png?table=block&amp;id=323b48bf-ea2c-8000-b8bb-ea512840d3c5&amp;t=323b48bf-ea2c-8000-b8bb-ea512840d3c5" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-323b48bfea2c807ea219cc6c45cf2087"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-323b48bfea2c8018a628e80c13903dd1"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A01a135ff-dfd1-489b-885e-b1d41fbe819d%3Aimage.png?table=block&amp;id=323b48bf-ea2c-8018-a628-e80c13903dd1&amp;t=323b48bf-ea2c-8018-a628-e80c13903dd1" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-323b48bfea2c8092ac26df72b32d2aed"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-323b48bfea2c80e5a559e5741c4b7dab"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A2d2f10df-1103-4508-963d-b545cfda1f9e%3Aimage.png?table=block&amp;id=323b48bf-ea2c-80e5-a559-e5741c4b7dab&amp;t=323b48bf-ea2c-80e5-a559-e5741c4b7dab" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-323b48bfea2c809f82a9c9ccec3f3390"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-323b48bfea2c80fe99c8cb252520580f"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A7dab9695-4c7c-4a66-b1d4-864c7e7bafa3%3Aimage.png?table=block&amp;id=323b48bf-ea2c-80fe-99c8-cb252520580f&amp;t=323b48bf-ea2c-80fe-99c8-cb252520580f" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-323b48bfea2c80479c1af027844e194b"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-323b48bfea2c8096b238c16c1d9a5ca1"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Aff831324-1436-4a1d-9f10-7a945134e4a3%3Aimage.png?table=block&amp;id=323b48bf-ea2c-8096-b238-c16c1d9a5ca1&amp;t=323b48bf-ea2c-8096-b238-c16c1d9a5ca1" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-323b48bfea2c80fcb9e4f4ad209e30c1"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-323b48bfea2c805782c8d6788476a447"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Abd77346f-786c-481d-9ac1-a57a5cb8b9e5%3Aimage.png?table=block&amp;id=323b48bf-ea2c-8057-82c8-d6788476a447&amp;t=323b48bf-ea2c-8057-82c8-d6788476a447" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-323b48bfea2c809e8715db02a4c79fd7"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-323b48bfea2c8041a754e4453d68d113"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A0e7e0640-a67d-4527-a433-25dae3e86016%3Aimage.png?table=block&amp;id=323b48bf-ea2c-8041-a754-e4453d68d113&amp;t=323b48bf-ea2c-8041-a754-e4453d68d113" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-323b48bfea2c8055b3c7e7eead53cf81"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-323b48bfea2c8064ac6af901b7b5cf5f"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A92e060c2-e251-4614-b8d4-68cba5fb831c%3Aimage.png?table=block&amp;id=323b48bf-ea2c-8064-ac6a-f901b7b5cf5f&amp;t=323b48bf-ea2c-8064-ac6a-f901b7b5cf5f" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-323b48bfea2c809eaa72c4376fe83989"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-323b48bfea2c805d972def228bc8de7f"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A19c3596c-a34d-473d-abf5-2b4c6ac58115%3Aimage.png?table=block&amp;id=323b48bf-ea2c-805d-972d-ef228bc8de7f&amp;t=323b48bf-ea2c-805d-972d-ef228bc8de7f" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-323b48bfea2c80978291c35f70b06659"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-323b48bfea2c80d6a2a4dd54cd54f814"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Afb4734bb-bcc1-4393-ad7d-31b4ff48db4f%3Aimage.png?table=block&amp;id=323b48bf-ea2c-80d6-a2a4-dd54cd54f814&amp;t=323b48bf-ea2c-80d6-a2a4-dd54cd54f814" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-323b48bfea2c80e4898ade2645fb9661">受限于手机接收天线，有的手机2根天线，有的4根天线</div><div class="notion-text notion-block-323b48bfea2c80d9ac58da16ffb235c5">T=Transmit 发射天线</div><div class="notion-text notion-block-323b48bfea2c80b2a9c7d6eb1ff19c67">R=Receive 接收天线</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-323b48bfea2c80328246d5683f5b817d"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Aa16f8b60-f0e1-4b26-817e-e003da895b71%3Aimage.png?table=block&amp;id=323b48bf-ea2c-8032-8246-d5683f5b817d&amp;t=323b48bf-ea2c-8032-8246-d5683f5b817d" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-323b48bfea2c80b38119c82002239c48"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-323b48bfea2c8074a3e5dc7aebcc2712"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A7477bcc9-bc68-4cb5-8745-dceb0f59aaf9%3Aimage.png?table=block&amp;id=323b48bf-ea2c-8074-a3e5-dc7aebcc2712&amp;t=323b48bf-ea2c-8074-a3e5-dc7aebcc2712" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-323b48bfea2c80d998afefdb5320bd3c"> </div><div class="notion-blank notion-block-323b48bfea2c80a5ad64f60e6de16d19"> </div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Claude Code 从 0 到 1 全攻略]]></title>
            <link>https://blog.cpunull.me/article/ClaudeCodeUse</link>
            <guid>https://blog.cpunull.me/article/ClaudeCodeUse</guid>
            <pubDate>Sat, 21 Feb 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[Claude Code使用]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-30eb48bfea2c80b6b5c9d11c0e357fea"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-30eb48bfea2c807fa64add22c0d6ccfb"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:639.9976196289062px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Abfe34f7a-36d5-404a-a8ba-6e09f6e36b7f%3Aclaude_code_terminal_1771689010880.png?table=block&amp;id=30eb48bf-ea2c-807f-a64a-dd22c0d6ccfb&amp;t=30eb48bf-ea2c-807f-a64a-dd22c0d6ccfb" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-30eb48bfea2c806ea360e8dccf9288a2">Claude Code 是 Anthropic 官方推出的一款命令行 AI 编程助手，可以直接在终端中与代码交互，实现代码生成、调试与工程管理等功能。本文将从安装配置到高级用法，系统性地带你掌握 Claude Code 的使用。</div><details class="notion-toggle notion-block-320b48bfea2c803fb865d543a029c9d1"><summary>发送提示词之前，如果觉得自己组织的语言不够通顺，可以将说的东西复制给大模型，让它根据意思写一份能让大模型精准识别意图的提示词，这样Claude Code执行后会更能够符合你的要求</summary><div></div></details><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-fb7792889aad4d259820cce4825c4d2d" data-id="fb7792889aad4d259820cce4825c4d2d"><span><div id="fb7792889aad4d259820cce4825c4d2d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#fb7792889aad4d259820cce4825c4d2d" title="📦 第一部分：环境搭建与基础交互"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">📦 第一部分：环境搭建与基础交互</span></span></h2><hr class="notion-hr notion-block-4b59cef384b64d4a91f5d3319aebf758"/><h3 class="notion-h notion-h2 notion-default notion-h-indent-1 notion-block-30eb48bfea2c81f0a15bcc86a4d277ec" data-id="30eb48bfea2c81f0a15bcc86a4d277ec"><span><div id="30eb48bfea2c81f0a15bcc86a4d277ec" class="notion-header-anchor"></div><a class="notion-hash-link" href="#30eb48bfea2c81f0a15bcc86a4d277ec" title="1.1 安装 Claude Code"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">1.1 安装 Claude Code</span></span></h3><h4 class="notion-h notion-h3 notion-default notion-h-indent-2 notion-block-30eb48bfea2c81de9d9cf86dd8a5b046" data-id="30eb48bfea2c81de9d9cf86dd8a5b046"><span><div id="30eb48bfea2c81de9d9cf86dd8a5b046" class="notion-header-anchor"></div><a class="notion-hash-link" href="#30eb48bfea2c81de9d9cf86dd8a5b046" title="前提条件"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">前提条件</span></span></h4><ul class="notion-list notion-list-disc notion-block-30eb48bfea2c818f9f0ccc10f595798b"><li><b>Node.js 18+</b>：Claude Code 基于 Node.js 运行，请确保系统已安装 Node.js 18.0 或更高版本。可通过 <code class="notion-inline-code">node --version</code> 查看版本。</li></ul><ul class="notion-list notion-list-disc notion-block-30eb48bfea2c813fa733d5a2c621020f"><li><b>Git</b>：Windows 用户需额外安装 <a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://gitforwindows.org/">Git for Windows</a>，macOS / Linux 通常已自带。</li></ul><h4 class="notion-h notion-h3 notion-default notion-h-indent-2 notion-block-30eb48bfea2c8196b4edc3be7a39d0fe" data-id="30eb48bfea2c8196b4edc3be7a39d0fe"><span><div id="30eb48bfea2c8196b4edc3be7a39d0fe" class="notion-header-anchor"></div><a class="notion-hash-link" href="#30eb48bfea2c8196b4edc3be7a39d0fe" title="安装命令"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">安装命令</span></span></h4><div class="notion-text notion-default notion-block-30eb48bfea2c81779b3dd9d7958a18d5">在终端中运行以下命令全局安装：</div><div class="notion-text notion-default notion-block-30eb48bfea2c816d8128cff81bd08341">安装完成后，验证是否安装成功：</div><div class="notion-text notion-default notion-block-30eb48bfea2c8112bd6fd8e682ea2768">启动 Claude Code 只需在项目目录下运行：</div><hr class="notion-hr notion-block-30eb48bfea2c81b7b671dded8a0ba820"/><h3 class="notion-h notion-h2 notion-default notion-h-indent-1 notion-block-30eb48bfea2c8114a420e3c5ccec9921" data-id="30eb48bfea2c8114a420e3c5ccec9921"><span><div id="30eb48bfea2c8114a420e3c5ccec9921" class="notion-header-anchor"></div><a class="notion-hash-link" href="#30eb48bfea2c8114a420e3c5ccec9921" title="1.2 登录与认证"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">1.2 登录与认证</span></span></h3><h4 class="notion-h notion-h3 notion-default notion-h-indent-2 notion-block-30eb48bfea2c817394d9e6e4363d84ec" data-id="30eb48bfea2c817394d9e6e4363d84ec"><span><div id="30eb48bfea2c817394d9e6e4363d84ec" class="notion-header-anchor"></div><a class="notion-hash-link" href="#30eb48bfea2c817394d9e6e4363d84ec" title="方式一：官方 Anthropic 账号登录（需代理）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">方式一：官方 Anthropic 账号登录（需代理）</span></span></h4><div class="notion-text notion-default notion-block-30eb48bfea2c8134a6c2d75783fb43aa">首次运行 <code class="notion-inline-code">claude</code> 命令时，会引导你通过浏览器登录 Anthropic 账号。<b>但由于 Anthropic 官方服务在国内无法直接访问，你需要在终端中先配置代理</b>：</div><div class="notion-callout notion-yellow_background_co notion-block-30eb48bfea2c817a90cee5317fe8e179"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="💡">💡</span></div><div class="notion-callout-text">请将 <code class="notion-inline-code">7890</code> 替换为你本地代理工具（如 Clash、V2Ray 等）的实际端口号。配置好代理后再运行 <code class="notion-inline-code">claude</code> 即可正常打开浏览器进行 OAuth 登录。</div></div><h4 class="notion-h notion-h3 notion-default notion-h-indent-2 notion-block-30eb48bfea2c81579c75f21847296051" data-id="30eb48bfea2c81579c75f21847296051"><span><div id="30eb48bfea2c81579c75f21847296051" class="notion-header-anchor"></div><a class="notion-hash-link" href="#30eb48bfea2c81579c75f21847296051" title="方式二：使用第三方 API Key"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">方式二：使用第三方 API Key</span></span></h4><div class="notion-text notion-default notion-block-30eb48bfea2c81d1b32bdebd5152ee4d">Claude Code 支持通过环境变量配置第三方 API Provider，无需官方账号也可使用。核心需要设置两个环境变量：</div><ul class="notion-list notion-list-disc notion-block-30eb48bfea2c81e49d2bc4b9edf4a9d5"><li><code class="notion-inline-code">ANTHROPIC_AUTH_TOKEN</code> — 你的第三方 API Key</li></ul><ul class="notion-list notion-list-disc notion-block-30eb48bfea2c8111af29d525d361c078"><li><code class="notion-inline-code">ANTHROPIC_BASE_URL</code> — 第三方 API 的兼容接口地址</li></ul><hr class="notion-hr notion-block-30eb48bfea2c81d8b0ece01d81d922d7"/><h3 class="notion-h notion-h2 notion-default notion-h-indent-1 notion-block-30eb48bfea2c81978b02d940551ef6fd" data-id="30eb48bfea2c81978b02d940551ef6fd"><span><div id="30eb48bfea2c81978b02d940551ef6fd" class="notion-header-anchor"></div><a class="notion-hash-link" href="#30eb48bfea2c81978b02d940551ef6fd" title="1.3 🇨🇳 国内推荐：使用智谱 GLM 接入 Claude Code"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">1.3 🇨🇳 国内推荐：使用智谱 GLM 接入 Claude Code</span></span></h3><div class="notion-text notion-default notion-block-30eb48bfea2c81009dc0f8f82d473561"><b>智谱 AI（GLM）</b> 提供了兼容 Anthropic API 的接口，这意味着你可以直接使用智谱的 API Key + 兼容地址来驱动 Claude Code，<b>无需代理、无需海外支付</b>，国内网络直连即可使用。</div><h4 class="notion-h notion-h3 notion-default notion-h-indent-2 notion-block-30eb48bfea2c815d86f2cbe3d90c4d24" data-id="30eb48bfea2c815d86f2cbe3d90c4d24"><span><div id="30eb48bfea2c815d86f2cbe3d90c4d24" class="notion-header-anchor"></div><a class="notion-hash-link" href="#30eb48bfea2c815d86f2cbe3d90c4d24" title="Step 1：注册并获取智谱 API Key"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Step 1：注册并获取智谱 API Key</span></span></h4><ol start="1" class="notion-list notion-list-numbered notion-block-30eb48bfea2c81dcb990fa9df063d802" style="list-style-type:decimal"><li>访问 <a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://bigmodel.cn">智谱 AI 开放平台 bigmodel.cn</a>，注册并登录账号</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-30eb48bfea2c810e9633e7025dacf10c" style="list-style-type:decimal"><li>进入「API Keys」管理页面（路径：控制台 → API Keys）</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-30eb48bfea2c81a8855ef0b1769ccfd0" style="list-style-type:decimal"><li>点击「创建 API Key」，复制并保存生成的密钥</li></ol><div class="notion-callout notion-teal_background_co notion-block-30eb48bfea2c812bbd28c1ed3762f00f"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="🎁">🎁</span></div><div class="notion-callout-text">智谱平台新注册用户通常会赠送一定额度的免费 Token，可以直接体验。后续也可以选择按量付费或购买「GLM Coding 套餐」获得更优惠的价格。</div></div><h4 class="notion-h notion-h3 notion-default notion-h-indent-2 notion-block-30eb48bfea2c81c8b1aef8dc1c2fcaef" data-id="30eb48bfea2c81c8b1aef8dc1c2fcaef"><span><div id="30eb48bfea2c81c8b1aef8dc1c2fcaef" class="notion-header-anchor"></div><a class="notion-hash-link" href="#30eb48bfea2c81c8b1aef8dc1c2fcaef" title="Step 2：配置环境变量"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Step 2：配置环境变量</span></span></h4><div class="notion-text notion-default notion-block-30eb48bfea2c81e6a313ec9ed7d0db5d">你需要设置两个关键的环境变量，告诉 Claude Code 使用智谱的 API 而非 Anthropic 官方：</div><div class="notion-text notion-default notion-block-30eb48bfea2c81769766c07c259da73c"><b>方法 A：临时设置（适用于当前终端会话）</b></div><div class="notion-text notion-default notion-block-30eb48bfea2c8170b026d234b2152ed1"><b>方法 B：永久设置（推荐）</b></div><div class="notion-text notion-default notion-block-30eb48bfea2c816da9abcd7e1b332583">Linux / macOS：在 <code class="notion-inline-code">~/.bashrc</code> 或 <code class="notion-inline-code">~/.zshrc</code> 文件末尾添加上述 export 命令，保存后执行 <code class="notion-inline-code">source ~/.bashrc</code> 使其生效。</div><div class="notion-text notion-default notion-block-30eb48bfea2c81d68edee3d432c3f10d">Windows：通过「此电脑 → 属性 → 高级系统设置 → 环境变量」添加用户环境变量。</div><div class="notion-text notion-default notion-block-30eb48bfea2c8115b8e9c65e5c375106"><b>方法 C：通过 Claude Code 配置文件（最优雅）</b></div><div class="notion-text notion-default notion-block-30eb48bfea2c81a2a8bbdbe511c32ab9">编辑 <code class="notion-inline-code">~/.claude/settings.json</code> 文件（如不存在则新建），添加以下内容：</div><div class="notion-callout notion-blue_background_co notion-block-30eb48bfea2c812a8e70c26bded592c5"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="✅">✅</span></div><div class="notion-callout-text">使用配置文件的好处是不会影响全局环境变量，且每次启动 Claude Code 时会自动加载，无需手动设置。</div></div><h4 class="notion-h notion-h3 notion-default notion-h-indent-2 notion-block-30eb48bfea2c810d82bcd341ea8ed970" data-id="30eb48bfea2c810d82bcd341ea8ed970"><span><div id="30eb48bfea2c810d82bcd341ea8ed970" class="notion-header-anchor"></div><a class="notion-hash-link" href="#30eb48bfea2c810d82bcd341ea8ed970" title="Step 3：启动验证"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Step 3：启动验证</span></span></h4><div class="notion-text notion-default notion-block-30eb48bfea2c812e8456cd94d15ba59c">配置完成后，在项目目录下启动 Claude Code：</div><div class="notion-text notion-default notion-block-30eb48bfea2c81f3b3d7c7350b93d2d2">如果一切配置正确，Claude Code 将跳过官方 OAuth 登录流程，直接通过智谱 GLM 的 API 接入。你会看到正常的交互界面，可以开始对话了。</div><h4 class="notion-h notion-h3 notion-default notion-h-indent-2 notion-block-30eb48bfea2c81bbb1d8e817418072c1" data-id="30eb48bfea2c81bbb1d8e817418072c1"><span><div id="30eb48bfea2c81bbb1d8e817418072c1" class="notion-header-anchor"></div><a class="notion-hash-link" href="#30eb48bfea2c81bbb1d8e817418072c1" title="智谱 GLM 接入地址速查"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">智谱 GLM 接入地址速查</span></span></h4><table class="notion-simple-table notion-block-30eb48bfea2c811b8763d65432cadb9d"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-30eb48bfea2c81b79679c6effa91a2a0"><td class="" style="width:120px"><div class="notion-simple-table-cell">网络环境</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">ANTHROPIC_BASE_URL</code></div></td><td class="" style="width:333.2992401123047px"><div class="notion-simple-table-cell">说明</div></td></tr><tr class="notion-simple-table-row notion-block-30eb48bfea2c8149a36ff22a12a6a507"><td class="" style="width:120px"><div class="notion-simple-table-cell">🇨🇳 国内直连</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">https://open.bigmodel.cn/api/anthropic</code></div></td><td class="" style="width:333.2992401123047px"><div class="notion-simple-table-cell">推荐国内用户使用</div></td></tr><tr class="notion-simple-table-row notion-block-30eb48bfea2c81b7be10e3d8cff8fb9b"><td class="" style="width:120px"><div class="notion-simple-table-cell">🌐 国际线路</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">https://api.z.ai/api/anthropic</code></div></td><td class="" style="width:333.2992401123047px"><div class="notion-simple-table-cell">面向海外用户 (z.ai)</div></td></tr></tbody></table><blockquote class="notion-quote notion-default notion-block-30eb48bfea2c8176bcb0faa98dad8168"><div>💡 <b>小结：</b> 安装 Claude Code 只需一条 npm 命令。登录方面，海外用户可直接使用 Anthropic 官方 OAuth（需代理），国内用户推荐使用智谱 GLM 方案 —— 只需设置两个环境变量即可免代理直连使用，体验与官方一致。</div></blockquote><div class="notion-blank notion-block-30eb48bfea2c8093b309dafcc8d170a8"> </div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-eaf76a11779c47cf88385573befb5268" data-id="eaf76a11779c47cf88385573befb5268"><span><div id="eaf76a11779c47cf88385573befb5268" class="notion-header-anchor"></div><a class="notion-hash-link" href="#eaf76a11779c47cf88385573befb5268" title="⚙️ 第二部分：复杂任务处理与终端控制"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">⚙️ 第二部分：复杂任务处理与终端控制</span></span></h2><h3 class="notion-h notion-h2 notion-default notion-h-indent-1 notion-block-30eb48bfea2c81198631e872d714228a" data-id="30eb48bfea2c81198631e872d714228a"><span><div id="30eb48bfea2c81198631e872d714228a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#30eb48bfea2c81198631e872d714228a" title="2.1 在 Claude Code 中执行终端命令"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2.1 在 Claude Code 中执行终端命令</span></span></h3><div class="notion-text notion-default notion-block-30eb48bfea2c81e3a141d457bb26be77">Claude Code 不仅能生成和编辑代码，还可以直接在终端中执行命令。只需在输入框中以 <code class="notion-inline-code">!</code> 开头，后接你想执行的 Bash（或 Shell）命令即可：</div><div class="notion-text notion-default notion-block-30eb48bfea2c81e28b27fc0d70a46e20">使用 <code class="notion-inline-code">!</code> 前缀执行的命令会绕过 Claude 的自然语言理解，直接调用系统 Shell。命令的输出会显示在终端中，Claude 也能感知到执行结果，方便后续基于输出进行分析或操作。</div><div class="notion-callout notion-blue_background_co notion-block-30eb48bfea2c81e8a4d3e241a4279ede"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="💡">💡</span></div><div class="notion-callout-text"><b>小技巧：</b> Claude Code 会继承你当前的 Shell 环境，包括环境变量、别名等。这意味着你在终端中能用的工具和命令，在 Claude Code 中同样可以使用。而且命令之间的状态是可以保持的——比如你先 <code class="notion-inline-code">export</code> 一个变量，后续命令中依然可以访问到。</div></div><hr class="notion-hr notion-block-30eb48bfea2c8114a057d760ed88e329"/><h3 class="notion-h notion-h2 notion-default notion-h-indent-1 notion-block-30eb48bfea2c8149b1d9e10d875ff9d0" data-id="30eb48bfea2c8149b1d9e10d875ff9d0"><span><div id="30eb48bfea2c8149b1d9e10d875ff9d0" class="notion-header-anchor"></div><a class="notion-hash-link" href="#30eb48bfea2c8149b1d9e10d875ff9d0" title="2.2 三种交互模式切换（Shift + Tab）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2.2 三种交互模式切换（Shift + Tab）</span></span></h3><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-30eb48bfea2c80c0bf32d886c98e3055"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:672px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Afefef53d-a924-4ab7-beac-7d7beee4606b%3Athree_modes_diagram_1771689030716.png?table=block&amp;id=30eb48bf-ea2c-80c0-bf32-d886c98e3055&amp;t=30eb48bf-ea2c-80c0-bf32-d886c98e3055" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-default notion-block-30eb48bfea2c819eb71bcb383a5dd739">Claude Code 提供了三种交互模式，通过按 <code class="notion-inline-code"><b>Shift + Tab</b></code> 可以在输入框中循环切换。不同模式下 Claude 的自主权限不同，适合不同的使用场景：</div><table class="notion-simple-table notion-block-30eb48bfea2c81acac31e75f71bfa49f"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-30eb48bfea2c81869a40e65c04cc7e6d"><td class="" style="width:120px"><div class="notion-simple-table-cell">模式</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">文件编辑</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">执行命令</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">适用场景</div></td></tr><tr class="notion-simple-table-row notion-block-30eb48bfea2c8199a75dd384541b13d8"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>Default（默认）</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">❓ 需确认</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">❓ 需确认</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">日常开发、不确定代码改动时</div></td></tr><tr class="notion-simple-table-row notion-block-30eb48bfea2c81ff8609e5cf8f6bec54"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>Auto-accept Edits</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">✅ 自动执行</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">❓ 需确认</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">信任 Claude 的编辑能力但命令谨慎</div></td></tr><tr class="notion-simple-table-row notion-block-30eb48bfea2c81f9b43cd759017bdfec"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>Plan Mode</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">🚫 只读不改</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">🚫 只读不改</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">复杂任务先规划、代码审查分析</div></td></tr></tbody></table><div class="notion-text notion-default notion-block-30eb48bfea2c8135b62de3472683cbf9"><b>Default 模式（默认）</b>：Claude 在每次编辑文件或执行命令前都会询问你的确认。这是最安全的模式，适合对修改内容不太确定的场景。</div><div class="notion-text notion-default notion-block-30eb48bfea2c8159ab62d3d232a29283"><b>Auto-accept Edits 模式</b>：Claude 会直接编辑文件而无需确认，但执行 Shell 命令时仍会要求你批准。适合你信任 Claude 的代码能力、但想要对执行命令保持控制的场景。</div><div class="notion-text notion-default notion-block-30eb48bfea2c81f4b84ecb99c6dc73d6"><b>Plan Mode（规划模式）</b>：Claude 只使用只读工具分析代码结构和问题，输出一份行动计划供你审阅，不会对代码做任何实际修改。非常适合：</div><ul class="notion-list notion-list-disc notion-block-30eb48bfea2c81839177d5898e23dea5"><li>复杂的重构任务——先让 Claude 分析影响范围再动手</li></ul><ul class="notion-list notion-list-disc notion-block-30eb48bfea2c8165a320ff92a56dd455"><li>不熟悉的代码库——先梳理架构和依赖关系</li></ul><ul class="notion-list notion-list-disc notion-block-30eb48bfea2c81009104c113c3253c5b"><li>团队协作——生成可分享的实施方案</li></ul><div class="notion-callout notion-yellow_background_co notion-block-30eb48bfea2c8121bd39fa0087424176"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="⌨️">⌨️</span></div><div class="notion-callout-text"><b>操作方式：</b> 在输入框中按 <code class="notion-inline-code"><b>Shift + Tab</b></code> 即可在三种模式间循环切换。当前激活的模式会在输入框旁边显示标识。建议日常使用默认模式，遇到复杂任务时切换到 Plan Mode 先理清思路再切回默认模式执行。</div></div><hr class="notion-hr notion-block-30eb48bfea2c81f7929cdc19427180cd"/><h3 class="notion-h notion-h2 notion-default notion-h-indent-1 notion-block-30eb48bfea2c8164971ed87d24ed6a28" data-id="30eb48bfea2c8164971ed87d24ed6a28"><span><div id="30eb48bfea2c8164971ed87d24ed6a28" class="notion-header-anchor"></div><a class="notion-hash-link" href="#30eb48bfea2c8164971ed87d24ed6a28" title="2.3 跳过权限检测（危险模式）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2.3 跳过权限检测（危险模式）</span></span></h3><div class="notion-text notion-default notion-block-30eb48bfea2c81a5a86bf1ccc9c3860b">在某些场景下（如 CI/CD 流水线、本地沙箱环境），你可能不想每次都手动确认权限弹窗。Claude Code 提供了一个 <b>跳过权限检测</b> 的启动参数：</div><div class="notion-text notion-default notion-block-30eb48bfea2c81aa83afec9b0a3fdedd">启用此参数后，Claude 会端到端地执行任务，不会暂停询问文件编辑或命令执行的权限。这可以显著提升自动化流程的效率。</div><div class="notion-callout notion-red_background_co notion-block-30eb48bfea2c81239063defd499a4cce"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="⚠️">⚠️</span></div><div class="notion-callout-text"><b>安全警告：</b> 此模式下 Claude 可能执行具有破坏性的命令（如删除文件、修改系统配置等），且不会给你确认的机会。
<b>仅建议在以下场景使用：</b>
• 本地开发环境，且有 Git 版本控制保底
• Docker 容器或沙箱环境中
• CI/CD 自动化流水线
<b>切勿在生产环境启用此参数！</b></div></div><hr class="notion-hr notion-block-30eb48bfea2c819dbcb0f3b3fc356df1"/><h3 class="notion-h notion-h2 notion-default notion-h-indent-1 notion-block-30eb48bfea2c81059133f3a7ba411b0f" data-id="30eb48bfea2c81059133f3a7ba411b0f"><span><div id="30eb48bfea2c81059133f3a7ba411b0f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#30eb48bfea2c81059133f3a7ba411b0f" title="2.4 后台任务管理（Background Tasks）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2.4 后台任务管理（Background Tasks）</span></span></h3><div class="notion-text notion-default notion-block-30eb48bfea2c81daae01c32c4ac5808e">当 Claude 建议执行一个耗时较长的命令时（如项目构建、运行测试、启动开发服务器等），你不必干等它执行完毕。Claude Code 支持将命令发送到后台运行，让你继续进行其他交互。</div><h4 class="notion-h notion-h3 notion-default notion-h-indent-2 notion-block-30eb48bfea2c8138a341cbb7dac5053a" data-id="30eb48bfea2c8138a341cbb7dac5053a"><span><div id="30eb48bfea2c8138a341cbb7dac5053a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#30eb48bfea2c8138a341cbb7dac5053a" title="如何使用"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">如何使用</span></span></h4><div class="notion-text notion-default notion-block-30eb48bfea2c8137a12bed036ddea296">当 Claude 提示你确认执行某个命令时，按 <code class="notion-inline-code"><b>Ctrl + B</b></code>（而不是回车确认），该命令就会被送入后台执行。</div><div class="notion-text notion-default notion-block-30eb48bfea2c8120b0cbc8e6c05535c3">后台任务的特点：</div><ul class="notion-list notion-list-disc notion-block-30eb48bfea2c8177a3d6e30c2d933d44"><li>每个后台任务会被分配一个唯一的任务 ID，便于追踪</li></ul><ul class="notion-list notion-list-disc notion-block-30eb48bfea2c81bb89c0ce6892e2496c"><li>任务在后台异步执行，不阻塞当前的对话交互</li></ul><ul class="notion-list notion-list-disc notion-block-30eb48bfea2c8165a3d4f46a7a937270"><li>Claude 可以在需要时获取后台任务的输出结果</li></ul><ul class="notion-list notion-list-disc notion-block-30eb48bfea2c81c38f08d294e685b98e"><li>非常适合运行构建工具、测试框架、包管理器或开发服务器等耗时操作</li></ul><h4 class="notion-h notion-h3 notion-default notion-h-indent-2 notion-block-30eb48bfea2c812cb646f71a78b78cc5" data-id="30eb48bfea2c812cb646f71a78b78cc5"><span><div id="30eb48bfea2c812cb646f71a78b78cc5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#30eb48bfea2c812cb646f71a78b78cc5" title="典型使用场景"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">典型使用场景</span></span></h4><div class="notion-callout notion-yellow_background_co notion-block-30eb48bfea2c81898faee3208322d506"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="📝">📝</span></div><div class="notion-callout-text"><b>注意事项：
</b>• 如果你使用 <b>tmux</b>，由于 Ctrl+B 是 tmux 的默认前缀键，你需要按 <b>两次 Ctrl+B</b> 才能触发后台任务功能
• macOS 系统下 Ctrl+B 可能与系统快捷键（光标后移）冲突，如遇到此问题可在系统偏好设置中调整键位绑定</div></div><hr class="notion-hr notion-block-30eb48bfea2c81c78b6dd9d67d474c3e"/><blockquote class="notion-quote notion-default notion-block-30eb48bfea2c81d69250ea9d216d90bf"><div>💡 <b>本节小结：</b> 用 <code class="notion-inline-code">!</code> 前缀直接执行 Shell 命令；Shift+Tab 在默认模式、自动接受编辑模式和计划模式间切换；<code class="notion-inline-code">--dangerously-skip-permissions</code> 在安全环境下跳过所有确认弹窗；Ctrl+B 将耗时命令放入后台运行。这些快捷操作组合使用，可以大幅提升与 Claude Code 协作的效率。</div></blockquote><hr class="notion-hr notion-block-b61b95789f5844bb9748b948980296d9"/><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-4f7df33f3aa844deb33742ba31d6fec1" data-id="4f7df33f3aa844deb33742ba31d6fec1"><span><div id="4f7df33f3aa844deb33742ba31d6fec1" class="notion-header-anchor"></div><a class="notion-hash-link" href="#4f7df33f3aa844deb33742ba31d6fec1" title="🧠 第三部分：多模态与上下文管理"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">🧠 第三部分：多模态与上下文管理</span></span></h2><h3 class="notion-h notion-h2 notion-default notion-h-indent-1 notion-block-30eb48bfea2c81a4be1dd0c6d9fae48a" data-id="30eb48bfea2c81a4be1dd0c6d9fae48a"><span><div id="30eb48bfea2c81a4be1dd0c6d9fae48a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#30eb48bfea2c81a4be1dd0c6d9fae48a" title="3.1 版本回滚（Rewind）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">3.1 版本回滚（Rewind）</span></span></h3><div class="notion-text notion-default notion-block-30eb48bfea2c813f9ffffb2373bf474a">Claude Code 在每次修改文件时会自动创建检查点（Checkpoint）。当你发现 Claude 生成的代码有问题时，可以轻松回滚到之前的状态。</div><h4 class="notion-h notion-h3 notion-default notion-h-indent-2 notion-block-30eb48bfea2c81988f73ee2b9ac54be1" data-id="30eb48bfea2c81988f73ee2b9ac54be1"><span><div id="30eb48bfea2c81988f73ee2b9ac54be1" class="notion-header-anchor"></div><a class="notion-hash-link" href="#30eb48bfea2c81988f73ee2b9ac54be1" title="方式一：/rewind 命令"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">方式一：/rewind 命令</span></span></h4><div class="notion-text notion-default notion-block-30eb48bfea2c8150a11ec1f7b83def14">在对话中输入 <code class="notion-inline-code">/rewind</code> 命令，Claude 会列出最近的检查点，你可以选择回滚到哪个时间点。回滚操作会撤销 Claude 对文件所做的更改。</div><h4 class="notion-h notion-h3 notion-default notion-h-indent-2 notion-block-30eb48bfea2c81f0a1fbf2e873b50367" data-id="30eb48bfea2c81f0a1fbf2e873b50367"><span><div id="30eb48bfea2c81f0a1fbf2e873b50367" class="notion-header-anchor"></div><a class="notion-hash-link" href="#30eb48bfea2c81f0a1fbf2e873b50367" title="方式二：ESC 快捷键"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">方式二：ESC 快捷键</span></span></h4><div class="notion-text notion-default notion-block-30eb48bfea2c8170b992d2579ef36bd0">连按两次 <code class="notion-inline-code"><b>ESC</b></code> 键可以快速进入检查点选择界面，手动选择你想回滚到的具体时间点。</div><div class="notion-callout notion-red_background_co notion-block-30eb48bfea2c81ecbeace3c74e755a4b"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="⚠️">⚠️</span></div><div class="notion-callout-text"><b>回滚范围限制：</b> Rewind 只能回滚 Claude Code <b>自己生成或修改的文件</b>。通过终端命令（如 <code class="notion-inline-code">npm install</code>）生成的依赖文件（如 <code class="notion-inline-code">node_modules</code>）不会被回滚。因此，建议你始终配合 <b>Git 进行版本管理</b>，在重大修改前先 <code class="notion-inline-code">git commit</code>，这样即使出问题也能完全恢复。</div></div><hr class="notion-hr notion-block-30eb48bfea2c819e8175f303479940ff"/><h3 class="notion-h notion-h2 notion-default notion-h-indent-1 notion-block-30eb48bfea2c81db93e2f646857f3152" data-id="30eb48bfea2c81db93e2f646857f3152"><span><div id="30eb48bfea2c81db93e2f646857f3152" class="notion-header-anchor"></div><a class="notion-hash-link" href="#30eb48bfea2c81db93e2f646857f3152" title="3.2 图片处理（多模态输入）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">3.2 图片处理（多模态输入）</span></span></h3><div class="notion-text notion-default notion-block-30eb48bfea2c814ab59ade7cde66944f">Claude Code 支持多模态输入，你可以直接发送图片给 Claude 进行分析、理解和操作。</div><h4 class="notion-h notion-h3 notion-default notion-h-indent-2 notion-block-30eb48bfea2c81a1a3dfcf16a287692d" data-id="30eb48bfea2c81a1a3dfcf16a287692d"><span><div id="30eb48bfea2c81a1a3dfcf16a287692d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#30eb48bfea2c81a1a3dfcf16a287692d" title="如何发送图片"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">如何发送图片</span></span></h4><table class="notion-simple-table notion-block-30eb48bfea2c81dca18bc05f25cb1f98"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-30eb48bfea2c81bab5d5cf4c8c0b0c02"><td class="" style="width:120px"><div class="notion-simple-table-cell">操作方式</div></td><td class="" style="width:534.9975891113281px"><div class="notion-simple-table-cell">说明</div></td></tr><tr class="notion-simple-table-row notion-block-30eb48bfea2c81878418f510d5c8f9b8"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>拖入图片</b></div></td><td class="" style="width:534.9975891113281px"><div class="notion-simple-table-cell">直接将图片文件从文件管理器拖入到 Claude Code 的输入框中</div></td></tr><tr class="notion-simple-table-row notion-block-30eb48bfea2c8179af61cfe608b0b075"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>粘贴图片</b></div></td><td class="" style="width:534.9975891113281px"><div class="notion-simple-table-cell">先复制一张图片，然后在输入框中按 Alt+V (Windows) / Option+V (macOS) 粘贴</div></td></tr></tbody></table><div class="notion-text notion-default notion-block-30eb48bfea2c81f9835ef3390429ce5f">常见的图片处理场景：</div><ul class="notion-list notion-list-disc notion-block-30eb48bfea2c8108a445cd5977d0ca6e"><li>发送 UI 截图让 Claude 还原为代码</li></ul><ul class="notion-list notion-list-disc notion-block-30eb48bfea2c813a9644c5285b6f9f9b"><li>发送错误截图让 Claude 分析问题原因</li></ul><ul class="notion-list notion-list-disc notion-block-30eb48bfea2c81b7ad86fba0beafc260"><li>发送架构图让 Claude 理解系统设计</li></ul><hr class="notion-hr notion-block-30eb48bfea2c8187a555c1b55e28588d"/><h3 class="notion-h notion-h2 notion-default notion-h-indent-1 notion-block-30eb48bfea2c810a95cdee2844886251" data-id="30eb48bfea2c810a95cdee2844886251"><span><div id="30eb48bfea2c810a95cdee2844886251" class="notion-header-anchor"></div><a class="notion-hash-link" href="#30eb48bfea2c810a95cdee2844886251" title="3.3 安装 MCP Server"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">3.3 安装 MCP Server</span></span></h3><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-30eb48bfea2c80f783d8c52ae740f26d"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:640px"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A19dfff04-eaf2-4ccb-9e76-875b1f171d17%3Amcp_architecture_1771691369849.png?table=block&amp;id=30eb48bf-ea2c-80f7-83d8-c52ae740f26d&amp;t=30eb48bf-ea2c-80f7-83d8-c52ae740f26d" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-default notion-block-30eb48bfea2c816990f2e11230771d58"><b>MCP（Model Context Protocol）</b> 是一种标准协议，它允许 Claude Code 连接到各种外部工具和数据源。通过安装 MCP Server，Claude 可以在需要时调用封装好的 Tool 工具来执行特定任务，极大扩展了 Claude Code 的能力边界。</div><h4 class="notion-h notion-h3 notion-default notion-h-indent-2 notion-block-30eb48bfea2c81c589c0d6806aecea5a" data-id="30eb48bfea2c81c589c0d6806aecea5a"><span><div id="30eb48bfea2c81c589c0d6806aecea5a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#30eb48bfea2c81c589c0d6806aecea5a" title="添加 MCP Server"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">添加 MCP Server</span></span></h4><div class="notion-text notion-default notion-block-30eb48bfea2c8172b1e9c10e9e92881d">在 Claude Code 中输入 <code class="notion-inline-code">/mcp</code> 可以查看和管理所有已连接的 MCP Server，包括认证和状态检查。</div><hr class="notion-hr notion-block-30eb48bfea2c81bc898ff79767a1f5c6"/><h3 class="notion-h notion-h2 notion-default notion-h-indent-1 notion-block-30eb48bfea2c81458397eb2b1fd20c46" data-id="30eb48bfea2c81458397eb2b1fd20c46"><span><div id="30eb48bfea2c81458397eb2b1fd20c46" class="notion-header-anchor"></div><a class="notion-hash-link" href="#30eb48bfea2c81458397eb2b1fd20c46" title="3.4 恢复历史会话（Resume）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">3.4 恢复历史会话（Resume）</span></span></h3><div class="notion-text notion-default notion-block-30eb48bfea2c819b9683d6c041357eb7">Claude Code 会保存你的对话历史，方便你随时回到之前的工作上下文。</div><table class="notion-simple-table notion-block-30eb48bfea2c81c28923c8b672cfdeea"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-30eb48bfea2c81b9994ae4bafea69d63"><td class="" style="width:120px"><div class="notion-simple-table-cell">方式</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">命令</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">说明</div></td></tr><tr class="notion-simple-table-row notion-block-30eb48bfea2c81c09370ff659d4d743f"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>对话内恢复</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/resume</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">在对话中输入，列出历史对话列表，选择想恢复的会话</div></td></tr><tr class="notion-simple-table-row notion-block-30eb48bfea2c813f849cc793a01f543e"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>启动时继续</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">claude -c</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">启动时直接进入上一次的对话，无需选择</div></td></tr><tr class="notion-simple-table-row notion-block-30eb48bfea2c816aa9e2e5ec92b44d98"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>启动时选择</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">claude -r</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">启动时弹出历史对话列表，手动选择要恢复的会话</div></td></tr></tbody></table><hr class="notion-hr notion-block-30eb48bfea2c813e942ddaf9758c34c7"/><h3 class="notion-h notion-h2 notion-default notion-h-indent-1 notion-block-30eb48bfea2c818ea453cc0a96730c1d" data-id="30eb48bfea2c818ea453cc0a96730c1d"><span><div id="30eb48bfea2c818ea453cc0a96730c1d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#30eb48bfea2c818ea453cc0a96730c1d" title="3.5 使用 MCP 工具还原设计稿（Figma 实战）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">3.5 使用 MCP 工具还原设计稿（Figma 实战）</span></span></h3><div class="notion-text notion-default notion-block-30eb48bfea2c81b38f11cb54f7e3b306">通过集成 Figma MCP Server，Claude Code 可以直接读取 Figma 设计稿，并自动生成对应的前端代码。这是 MCP 最典型的应用场景之一。</div><h4 class="notion-h notion-h3 notion-default notion-h-indent-2 notion-block-30eb48bfea2c813f822fc76cf1ba8274" data-id="30eb48bfea2c813f822fc76cf1ba8274"><span><div id="30eb48bfea2c813f822fc76cf1ba8274" class="notion-header-anchor"></div><a class="notion-hash-link" href="#30eb48bfea2c813f822fc76cf1ba8274" title="配置步骤"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">配置步骤</span></span></h4><ol start="1" class="notion-list notion-list-numbered notion-block-30eb48bfea2c814f9b12cded39d65156" style="list-style-type:decimal"><li><b>开启 Figma MCP 支持</b>：打开 Figma 桌面端 → 菜单/偏好设置 → 启用 「Dev Mode MCP Server」</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-30eb48bfea2c81e3a8aadaee0f52d0a8" style="list-style-type:decimal"><li><b>在 Claude Code 中添加 Figma MCP</b>：</li></ol><ol start="1" class="notion-list notion-list-numbered notion-block-30eb48bfea2c8108a89ff0082d593d88" style="list-style-type:decimal"><li><b>认证连接</b>：在 Claude Code 中输入 <code class="notion-inline-code">/mcp</code> → 选择 Figma Server → 点击 Authenticate 完成 OAuth 授权</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-30eb48bfea2c81b986ebcb239d767f56" style="list-style-type:decimal"><li><b>使用</b>：在 Figma 中选中设计元素后，向 Claude 发送类似 「根据 Figma 选中的设计稿生成代码」 的指令，Claude 会自动调用 Figma MCP 读取设计数据并生成前端代码</li></ol><div class="notion-callout notion-blue_background_co notion-block-30eb48bfea2c81cca489d97687fc61ff"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="🎨">🎨</span></div><div class="notion-callout-text">Figma MCP 不仅可以从设计稿生成代码，还支持反向操作——将 Claude Code 构建的 UI 发送回 Figma，转换为可编辑的 Figma 图层。在对话中输入 「Send this to Figma」 即可。</div></div><hr class="notion-hr notion-block-30eb48bfea2c812b874fcb39242a7dbd"/><h3 class="notion-h notion-h2 notion-default notion-h-indent-1 notion-block-30eb48bfea2c81c599fcf66f7534e723" data-id="30eb48bfea2c81c599fcf66f7534e723"><span><div id="30eb48bfea2c81c599fcf66f7534e723" class="notion-header-anchor"></div><a class="notion-hash-link" href="#30eb48bfea2c81c599fcf66f7534e723" title="3.6 上下文压缩与清除"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">3.6 上下文压缩与清除</span></span></h3><div class="notion-text notion-default notion-block-30eb48bfea2c819398d8e3051bb81040">长时间的对话会导致上下文窗口过大，可能影响 Claude 的响应质量和速度。Claude Code 提供了两个命令来管理上下文：</div><table class="notion-simple-table notion-block-30eb48bfea2c819b8832f1fdb09162f1"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-30eb48bfea2c8109822bfea4d2a29731"><td class="" style="width:120px"><div class="notion-simple-table-cell">命令</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">作用</div></td><td class="" style="width:374.9975891113281px"><div class="notion-simple-table-cell">使用场景</div></td></tr><tr class="notion-simple-table-row notion-block-30eb48bfea2c810e91c4c4cbefd6c3d2"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code"><b>/compact</b></code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">智能压缩上下文，自动总结之前的对话，保留关键信息</div></td><td class="" style="width:374.9975891113281px"><div class="notion-simple-table-cell">感觉 Claude 响应变慢或上下文过长时使用</div></td></tr><tr class="notion-simple-table-row notion-block-30eb48bfea2c81288882e2b607f008c1"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code"><b>/clear</b></code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">完全清空当前对话和上下文，等同于新开一个窗口</div></td><td class="" style="width:374.9975891113281px"><div class="notion-simple-table-cell">切换到完全不同的任务时使用</div></td></tr></tbody></table><div class="notion-callout notion-yellow_background_co notion-block-30eb48bfea2c8179b7b0e2390906a5d2"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="💡">💡</span></div><div class="notion-callout-text"><b>建议：</b> 当你在同一个项目中工作较长时间后，优先使用 <code class="notion-inline-code">/compact</code> 压缩上下文，而不是 <code class="notion-inline-code">/clear</code> 完全清空。因为 <code class="notion-inline-code">/compact</code> 会保留之前对话中的关键决策和修改记录，避免 Claude 丢失重要上下文。只有在切换到完全无关的新任务时才使用 <code class="notion-inline-code">/clear</code>。</div></div><hr class="notion-hr notion-block-30eb48bfea2c81e2851ef95b1860d6fd"/><h3 class="notion-h notion-h2 notion-default notion-h-indent-1 notion-block-30eb48bfea2c814bb76df453ae5d4de2" data-id="30eb48bfea2c814bb76df453ae5d4de2"><span><div id="30eb48bfea2c814bb76df453ae5d4de2" class="notion-header-anchor"></div><a class="notion-hash-link" href="#30eb48bfea2c814bb76df453ae5d4de2" title="3.7 项目记忆文件（CLAUDE.md）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">3.7 项目记忆文件（CLAUDE.md）</span></span></h3><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-30eb48bfea2c804383e4fc210ec4d0bb"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:640px"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A68e8a7d2-568c-4f43-bd34-dc2d3149ebb4%3Aclaude_md_file_1771691297075.png?table=block&amp;id=30eb48bf-ea2c-8043-83e4-fc210ec4d0bb&amp;t=30eb48bf-ea2c-8043-83e4-fc210ec4d0bb" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-default notion-block-30eb48bfea2c81358249d805eb536833"><code class="notion-inline-code">CLAUDE.md</code> 是 Claude Code 最实用的功能之一。它是一个放在项目根目录下的 Markdown 文件，Claude Code 每次启动时会自动加载其中的内容，作为项目的「永久记忆」。</div><h4 class="notion-h notion-h3 notion-default notion-h-indent-2 notion-block-30eb48bfea2c818b91acc158d52325f5" data-id="30eb48bfea2c818b91acc158d52325f5"><span><div id="30eb48bfea2c818b91acc158d52325f5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#30eb48bfea2c818b91acc158d52325f5" title="创建方式"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">创建方式</span></span></h4><h4 class="notion-h notion-h3 notion-default notion-h-indent-2 notion-block-30eb48bfea2c8151b4d4d06cd31ce342" data-id="30eb48bfea2c8151b4d4d06cd31ce342"><span><div id="30eb48bfea2c8151b4d4d06cd31ce342" class="notion-header-anchor"></div><a class="notion-hash-link" href="#30eb48bfea2c8151b4d4d06cd31ce342" title="推荐写入的内容"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">推荐写入的内容</span></span></h4><div class="notion-callout notion-teal_background_co notion-block-30eb48bfea2c81fc952add33f72aa830"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="⭐">⭐</span></div><div class="notion-callout-text"><b>最佳实践：</b> 把项目的技术栈、命名规范、目录结构、常见坑点等都写进 <code class="notion-inline-code">CLAUDE.md</code>，可以大幅减少与 Claude 的重复沟通，生成的代码也会更符合项目的既有风格。团队协作时，这个文件还可以作为项目的「AI 入职手册」，让每个人使用 Claude Code 时都能得到一致的输出。</div></div><hr class="notion-hr notion-block-30eb48bfea2c8133a26bc9dbd39891eb"/><blockquote class="notion-quote notion-default notion-block-30eb48bfea2c8170831ec94d4f7e32e4"><div>💡 <b>本节小结：</b> <code class="notion-inline-code">/rewind</code> 回滚 Claude 的修改（配合 Git 更安全）；图片可拖入或 Alt+V 粘贴；MCP Server 扩展 Claude 能力（如 Figma 设计稿转代码）；<code class="notion-inline-code">/resume</code> 和 <code class="notion-inline-code">claude -c</code> 恢复历史会话；<code class="notion-inline-code">/compact</code> 压缩上下文、<code class="notion-inline-code">/clear</code> 清空对话；<code class="notion-inline-code">CLAUDE.md</code> 是项目的「永久记忆」，用 <code class="notion-inline-code">/init</code> 快速创建。</div></blockquote><hr class="notion-hr notion-block-763c47bbf78847cda22d2cba0b833944"/><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-7673dcb3191a496297c93dd606548f33" data-id="7673dcb3191a496297c93dd606548f33"><span><div id="7673dcb3191a496297c93dd606548f33" class="notion-header-anchor"></div><a class="notion-hash-link" href="#7673dcb3191a496297c93dd606548f33" title="🚀 第四部分：高级功能扩展与定制"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">🚀 第四部分：高级功能扩展与定制</span></span></h2><table class="notion-simple-table notion-block-1f882dfb3faf4d96891bef11327b00b3"><tbody><tr class="notion-simple-table-row notion-blue_background notion-simple-table-header-row notion-block-544cadc803d54261b9c1062876dd48e9"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>时间点</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>主题</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>要点说明</b></div></td></tr><tr class="notion-simple-table-row notion-block-b03d8d7db8ca4248b916f4598e90b3af"><td class="" style="width:120px"><div class="notion-simple-table-cell">29:46</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Hook</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">在特定事件（如文件保存、命令执行前后）触发自定义脚本，实现自动格式化、自动测试等</div></td></tr><tr class="notion-simple-table-row notion-block-9d69383697294eb3afd619bf7347becc"><td class="" style="width:120px"><div class="notion-simple-table-cell">33:16</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Agent Skill</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">为 Agent 定义专项技能，如&quot;代码审查&quot;&quot;单元测试生成&quot;，让 Agent 在特定领域表现更专业</div></td></tr><tr class="notion-simple-table-row notion-block-1606b9dbe4d94332a338fd51a5ae30e6"><td class="" style="width:120px"><div class="notion-simple-table-cell">36:00</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">SubAgent</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">创建子 Agent 分担任务，主 Agent 负责调度，SubAgent 各自处理子任务后汇总结果</div></td></tr><tr class="notion-simple-table-row notion-block-fe7a5877023e45df9f9cce96237586b5"><td class="" style="width:120px"><div class="notion-simple-table-cell">39:17</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Skill 与 SubAgent 的区别</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>Skill</b>：增强主 Agent 的单项能力；<b>SubAgent</b>：独立运行的子任务执行者，适合并行处理</div></td></tr><tr class="notion-simple-table-row notion-block-3bfad076822c4ee9bbcd53002c07bdb6"><td class="" style="width:120px"><div class="notion-simple-table-cell">40:38</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Plugin</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">插件化扩展，通过社区或自定义 Plugin 接入更多工具和服务</div></td></tr></tbody></table><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-4e1087fa4c2b485785eaf8ecedeb8751" data-id="4e1087fa4c2b485785eaf8ecedeb8751"><span><div id="4e1087fa4c2b485785eaf8ecedeb8751" class="notion-header-anchor"></div><a class="notion-hash-link" href="#4e1087fa4c2b485785eaf8ecedeb8751" title="4.1 Hooks：自定义事件驱动脚本"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">4.1 Hooks：自定义事件驱动脚本</span></span></h3><div class="notion-text notion-block-9ae0136ff0934db4addf6e0fc699ebe1"><b>Hooks</b> 是 Claude Code 的事件钩子机制，允许你在特定事件发生时自动执行自定义脚本。核心思想是<b>事件驱动</b> —— 当 Claude Code 内部发生某个事件（如任务完成、需要权限审批），自动触发你预设的操作。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-90de8ae2732b406c83e26f097afce982" data-id="90de8ae2732b406c83e26f097afce982"><span><div id="90de8ae2732b406c83e26f097afce982" class="notion-header-anchor"></div><a class="notion-hash-link" href="#90de8ae2732b406c83e26f097afce982" title="支持的 Hook 事件"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">支持的 Hook 事件</span></span></h4><table class="notion-simple-table notion-block-67ff307e99cc45a9af25713a017d6d6f"><tbody><tr class="notion-simple-table-row notion-blue_background notion-simple-table-header-row notion-block-ea711844f3c44304a8cc5815c65b1838"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>事件</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>触发时机</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>可阻止</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>典型用途</b></div></td></tr><tr class="notion-simple-table-row notion-block-27e663d5bb9f4514924992d6fb68dc14"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">Stop</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Claude 完成响应时</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">✅</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">任务完成通知、日志记录</div></td></tr><tr class="notion-simple-table-row notion-block-802f14c97e2a4bd99763dc2e1dbb4fac"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">Notification</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">发送通知时</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">❌</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">桌面通知、声音提醒</div></td></tr><tr class="notion-simple-table-row notion-block-52ab714235f34e789427aa65f2325b71"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">PreToolUse</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">工具调用前</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">✅</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">命令安全检查、自动审批</div></td></tr><tr class="notion-simple-table-row notion-block-fb93cc1f68384b66906e787bb99b9769"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">PostToolUse</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">工具调用后</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">❌</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">自动格式化、lint 检查</div></td></tr><tr class="notion-simple-table-row notion-block-a7e97383904e403c9ca08bf0e7c0b2b2"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">SessionStart</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">会话启动 / 恢复时</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">❌</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">注入上下文、环境初始化</div></td></tr><tr class="notion-simple-table-row notion-block-05ded2dd52614b8db45b599ab3c47389"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">SubagentStop</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">子代理任务完成时</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">❌</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">子任务完成通知</div></td></tr></tbody></table><div class="notion-callout notion-blue_background_co notion-block-bf54585dd06a4555803cc036f992138d"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="📌">📌</span></div><div class="notion-callout-text"><div class="notion-text notion-block-f47390627335425fa6f9eafb7c345497"><b>“可阻止”的含义：</b> 标记为 ✅ 的事件支持通过 Hook 脚本的退出码来控制流程。例如 <code class="notion-inline-code">PreToolUse</code> 的 Hook 返回退出码 <code class="notion-inline-code">2</code> 时，会阻止该工具调用；<code class="notion-inline-code">Stop</code> 的 Hook 返回 <code class="notion-inline-code">2</code> 时，Claude 会继续工作而不停下来。</div></div></div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-2a91468fb13a4d91b560c4109584bf83" data-id="2a91468fb13a4d91b560c4109584bf83"><span><div id="2a91468fb13a4d91b560c4109584bf83" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2a91468fb13a4d91b560c4109584bf83" title="两种配置方式"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">两种配置方式</span></span></h4><div class="notion-text notion-block-e001258b08aa47eeaa27b4588b37b7df"><b>方式一：</b><code class="notion-inline-code"><b>/hooks</b></code><b> 交互式菜单（推荐新手）</b></div><div class="notion-text notion-block-c23fca0f452c48ec851a0105ed0e93fc">在 Claude Code 对话中输入 <code class="notion-inline-code">/hooks</code>，会打开可视化管理界面，逐步引导你选择事件类型 → 设置匹配器 → 输入执行命令 → 选择作用域（全局 / 项目级）。</div><div class="notion-text notion-block-75dc0fd693fc41c086693887be54851a"><b>方式二：手动编辑 </b><code class="notion-inline-code"><b>settings.json</b></code></div><div class="notion-text notion-block-0fefcbce87c045678bed6c4b59b9edfa">编辑配置文件，支持三个层级：</div><table class="notion-simple-table notion-block-5540ee77906140ffa83c81481e26b6c9"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-e8cb18decde64dc3b0f52c41d12bb8fc"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>文件路径</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>作用域</b></div></td></tr><tr class="notion-simple-table-row notion-block-160d0c16e7994b4786df3efdf8e4fdfa"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">~/.claude/settings.json</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">全局生效（所有项目）</div></td></tr><tr class="notion-simple-table-row notion-block-737173eea1e14bc1a642869c69445378"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">.claude/settings.json</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">仅当前项目（可提交到 Git）</div></td></tr><tr class="notion-simple-table-row notion-block-bc5e33eac1924731b9b528a145dc6e85"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">.claude/settings.local.json</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">仅当前项目（被 Git 忽略）</div></td></tr></tbody></table><div class="notion-text notion-block-e98a762660de49e1bab39d330f8e5087">基本配置结构如下：</div><div class="notion-text notion-block-dfb2ea09070c401eb188c2b9d7eb4d95">每个 Hook 配置包含四个字段：</div><ul class="notion-list notion-list-disc notion-block-917adb0942dc461aa61ce47c8aabf119"><li><code class="notion-inline-code">matcher</code>：匹配条件，支持正则表达式，空字符串表示匹配所有</li></ul><ul class="notion-list notion-list-disc notion-block-a12fbc1b94164772a3220983c796a891"><li><code class="notion-inline-code">type</code>：固定为 <code class="notion-inline-code">&quot;command&quot;</code></li></ul><ul class="notion-list notion-list-disc notion-block-678cdb7b351d4ae98b53f178ac54021e"><li><code class="notion-inline-code">command</code>：要执行的 Shell 命令或脚本路径</li></ul><ul class="notion-list notion-list-disc notion-block-9b2ccc53941347468adc1b52fe7ff0a2"><li><code class="notion-inline-code">timeout</code>：超时时间（秒），防止脚本阻塞 Claude Code 主流程</li></ul><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-07f7c34c28ac4ede84bd76bbc2fdfb8e" data-id="07f7c34c28ac4ede84bd76bbc2fdfb8e"><span><div id="07f7c34c28ac4ede84bd76bbc2fdfb8e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#07f7c34c28ac4ede84bd76bbc2fdfb8e" title="Notification 匹配器速查"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Notification 匹配器速查</span></span></h4><div class="notion-text notion-block-6f7f87e14283415f8f1b19d4fec1b6f5"><code class="notion-inline-code">Notification</code> 事件通过 <code class="notion-inline-code">matcher</code> 字段区分不同的通知类型：</div><table class="notion-simple-table notion-block-fba910079c964469a5a5b5dd6c3db3fd"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-3605d531ec2b4761b2b37fb919fc1aa7"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>Matcher 值</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>触发条件</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>说明</b></div></td></tr><tr class="notion-simple-table-row notion-block-0ed750f362214c02873ba1bbb718cf50"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">permission_prompt</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">需要权限审批时</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">执行命令、写入文件前的确认弹窗</div></td></tr><tr class="notion-simple-table-row notion-block-2a39d9dc19f346afa740671366ef8348"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">idle_prompt</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">等待用户输入超过 60 秒</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">固定 60 秒触发，不可修改</div></td></tr><tr class="notion-simple-table-row notion-block-9042d2eb9b844beabdd113a638cb78c8"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">&quot;&quot;</code> (空字符串)</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">匹配所有通知</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">可作为兖底方案</div></td></tr></tbody></table><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-f4dea47a69d940878191d614fa1c2a43" data-id="f4dea47a69d940878191d614fa1c2a43"><span><div id="f4dea47a69d940878191d614fa1c2a43" class="notion-header-anchor"></div><a class="notion-hash-link" href="#f4dea47a69d940878191d614fa1c2a43" title="实战：WSL2 环境下的 Windows 桌面通知"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">实战：WSL2 环境下的 Windows 桌面通知</span></span></h4><div class="notion-text notion-block-1abed8e0539347589c614204e5789332">最实用的 Hook 场景 —— 让 Claude Code 在任务完成或需要交互时，弹出 Windows 原生 Toast 通知，再也不怕切窗口后错过消息。</div><div class="notion-text notion-block-16260a76455446cebb56c1023ba41640"><b>Step 1：创建通知脚本</b> <code class="notion-inline-code">~/.claude/hooks/notify.sh</code></div><div class="notion-text notion-block-cfe8bf396a6d45f6bec2543df94ac4ab">别忘了赋予执行权限：<code class="notion-inline-code">chmod +x ~/.claude/hooks/notify.sh</code></div><div class="notion-text notion-block-91a7ccc40ca940689dcae50bd928b0df"><b>Step 2：配置三个 Hook 触发器</b></div><div class="notion-text notion-block-3d3843d813fd493c82f5f1ac557e5827">在 <code class="notion-inline-code">~/.claude/settings.json</code> 中添加 <code class="notion-inline-code">hooks</code> 字段：</div><div class="notion-text notion-block-b789a4a432e24d11b20808547159b05d"><b>Step 3：重启 Claude Code 即可生效</b></div><table class="notion-simple-table notion-block-8ad13772d056404391ad72a7aef4171a"><tbody><tr class="notion-simple-table-row notion-blue_background notion-simple-table-header-row notion-block-6237a9e693054e769a80a9755fa450be"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>触发场景</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>通知消息</b></div></td><td class="" style="width:382.9975891113281px"><div class="notion-simple-table-cell"><b>对应 Hook</b></div></td></tr><tr class="notion-simple-table-row notion-block-1c5ad08b0cc54a9b982325d937217ef9"><td class="" style="width:120px"><div class="notion-simple-table-cell">Claude 完成任务响应</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">✅ 任务已完成</div></td><td class="" style="width:382.9975891113281px"><div class="notion-simple-table-cell"><code class="notion-inline-code">Stop</code></div></td></tr><tr class="notion-simple-table-row notion-block-4fc3174fcbe04fc584cbca1303bfd214"><td class="" style="width:120px"><div class="notion-simple-table-cell">需要你审批权限</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">⚠️ 需要权限审批</div></td><td class="" style="width:382.9975891113281px"><div class="notion-simple-table-cell"><code class="notion-inline-code">Notification</code>  • <code class="notion-inline-code">permission_prompt</code></div></td></tr><tr class="notion-simple-table-row notion-block-9da344a7bb6b4e8c8bdd9547004ee906"><td class="" style="width:120px"><div class="notion-simple-table-cell">等待输入超过 60 秒</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">💬 等待你的输入</div></td><td class="" style="width:382.9975891113281px"><div class="notion-simple-table-cell"><code class="notion-inline-code">Notification</code>  • <code class="notion-inline-code">idle_prompt</code></div></td></tr></tbody></table><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-322b48bfea2c8010b201e65b0fd3ba31" data-id="322b48bfea2c8010b201e65b0fd3ba31"><span><div id="322b48bfea2c8010b201e65b0fd3ba31" class="notion-header-anchor"></div><a class="notion-hash-link" href="#322b48bfea2c8010b201e65b0fd3ba31" title="4.2 /config配置"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">4.2 /config配置</span></span></h3><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-322b48bfea2c80e5b086ce44555e3491"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Aa5abd271-3565-4ac4-ba8a-4b6b50bae9b6%3Aimage.png?table=block&amp;id=322b48bf-ea2c-80e5-b086-ce44555e3491&amp;t=322b48bf-ea2c-80e5-b086-ce44555e3491" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-callout notion-yellow_background_co notion-block-017f0183c8e54ffbb43243378fce7a3d"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="💡">💡</span></div><div class="notion-callout-text"><div class="notion-text notion-block-09333188b8014d48806016f6d28c1650"><b>跨平台替代方案：</b>
• <b>macOS</b>：将脚本中的 PowerShell 命令替换为 <code class="notion-inline-code">osascript -e &#x27;display notification &quot;消息&quot; with title &quot;Claude Code&quot;&#x27;</code>
• <b>Linux 桌面</b>：使用 <code class="notion-inline-code">notify-send &quot;Claude Code&quot; &quot;消息&quot;</code> 即可
• <b>纯终端兖底</b>：<code class="notion-inline-code">echo -e &quot;\a&quot;</code> 发出终端响铃（最简方案）
• <b>timeout 建议</b>：设置为 10~15 秒，避免通知脚本阻塞 Claude Code 主流程</div></div></div><hr class="notion-hr notion-block-a3316941678e4699ab97087e89485647"/><blockquote class="notion-quote notion-block-9cbf5a8efc6f4927985293f52d95dc6d"><div>💡 <b>小结：</b> Hook 适合流程自动化（CI 级别），Skill 适合增强单一能力，SubAgent 适合拆分复杂任务并行执行。三者组合使用可以构建高度定制化的 AI 编码工作流。</div></blockquote><hr class="notion-hr notion-block-03f4c53143ce4958908fd08b1d9cf765"/><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-74358bdd5c294da3ab8ddf18c90597cb" data-id="74358bdd5c294da3ab8ddf18c90597cb"><span><div id="74358bdd5c294da3ab8ddf18c90597cb" class="notion-header-anchor"></div><a class="notion-hash-link" href="#74358bdd5c294da3ab8ddf18c90597cb" title="🤗 总结归纳"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">🤗 总结归纳</span></span></h2><div class="notion-text notion-block-ac38c72c997145298cfa63c54c60c184">本视频系统性地讲解了 Claude Code 的完整使用链路：</div><ol start="1" class="notion-list notion-list-numbered notion-block-d5ff6ed5598b41c18e6852aa2bc67fa4" style="list-style-type:decimal"><li><b>入门阶段</b>：安装配置 → 理解三种交互模式</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-4b4f7d5224b24f16a5f3fc4bed76c98f" style="list-style-type:decimal"><li><b>进阶阶段</b>：终端命令 → Plan Mode → 后台任务，处理复杂项目</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-656bce496b814071b12e4dbbf09e6a5d" style="list-style-type:decimal"><li><b>多模态与上下文</b>：图片理解 → MCP 集成（Figma 实战）→ <a target="_blank" rel="noopener noreferrer" class="notion-link" href="http://CLAUDE.md">CLAUDE.md</a> 项目记忆</li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-257a9ab44f9e472a99904ecbe63404d7" style="list-style-type:decimal"><li><b>高级定制</b>：Hook 自动化 → Agent Skill 专项增强 → SubAgent 任务拆分 → Plugin 生态扩展</li></ol><div class="notion-callout notion-yellow_background_co notion-block-43b144c0959040b1869b5df436dc4f25"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="⭐">⭐</span></div><div class="notion-callout-text"><div class="notion-text notion-block-2d6a47dffeda40aeaeb60db95ac92473"><b>推荐实践路径：</b> 先掌握三种模式 + <a target="_blank" rel="noopener noreferrer" class="notion-link" href="http://CLAUDE.md">CLAUDE.md</a> → 再接入 MCP Server 扩展能力 → 最后探索 Hook / Skill / SubAgent 构建自己的 AI 编码工作流</div></div></div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-c4a4d5277f664a178794b89f604e1fb4" data-id="c4a4d5277f664a178794b89f604e1fb4"><span><div id="c4a4d5277f664a178794b89f604e1fb4" class="notion-header-anchor"></div><a class="notion-hash-link" href="#c4a4d5277f664a178794b89f604e1fb4" title="📎 参考资料"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">📎 参考资料</span></span></h2><ul class="notion-list notion-list-disc notion-block-36672878e8aa4e45a831c3ce02b44d40"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://www.bilibili.com/video/BV14rzQB9EJj/">视频原链接：Claude Code 从 0 到 1 全攻略 — B站</a></li></ul><ul class="notion-list notion-list-disc notion-block-74e43737a0464750bae538addd0efe32"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://space.bilibili.com/">马克的技术工作坊 — B站主页</a></li></ul></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WSL进行更新]]></title>
            <link>https://blog.cpunull.me/article/wsl-update</link>
            <guid>https://blog.cpunull.me/article/wsl-update</guid>
            <pubDate>Sat, 07 Mar 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[WSL进行更新]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-31cb48bfea2c80f8bceac3f2d5180dc7"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-text notion-block-31cb48bfea2c80cbb6a4e26ace58e0c0">在 <b>Windows Subsystem for Linux (WSL)</b> 中更新一般有两种情况：</div><div class="notion-text notion-block-31cb48bfea2c80a0a176d85bce4ebe00">1️⃣ 更新 <b>WSL 本身（WSL 内核 / 组件）</b></div><div class="notion-text notion-block-31cb48bfea2c8017b52ecad2a563c1e4">2️⃣ 更新 <b>WSL 里的 Linux 发行版（如 Ubuntu、Debian 等）</b></div><div class="notion-text notion-block-31cb48bfea2c80ff9023dd06ab457bb1">我分别给你说明 👇</div><hr class="notion-hr notion-block-31cb48bfea2c8095a477eae2f8b51453"/><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-31cb48bfea2c80538dc6c8eaa4e71c01" data-id="31cb48bfea2c80538dc6c8eaa4e71c01"><span><div id="31cb48bfea2c80538dc6c8eaa4e71c01" class="notion-header-anchor"></div><a class="notion-hash-link" href="#31cb48bfea2c80538dc6c8eaa4e71c01" title="一、更新 WSL 本身（推荐先做）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">一、更新 WSL 本身（推荐先做）</span></span></h2><div class="notion-text notion-block-31cb48bfea2c80108cf8fbbc2d632a0f">在 <b>Windows PowerShell 或 CMD</b> 里运行：</div><div class="notion-text notion-block-31cb48bfea2c8029b14bf58d833916e2">作用：</div><ul class="notion-list notion-list-disc notion-block-31cb48bfea2c80bcbe50c22625bfed1e"><li>更新 WSL 内核</li></ul><ul class="notion-list notion-list-disc notion-block-31cb48bfea2c806d9034d22b305cf21f"><li>更新 WSL 组件</li></ul><ul class="notion-list notion-list-disc notion-block-31cb48bfea2c80fb8f53d7ffb034c51b"><li>适用于 WSL2</li></ul><div class="notion-text notion-block-31cb48bfea2c8087b501f11a930c6a52">更新完成后可以查看版本：</div><div class="notion-text notion-block-31cb48bfea2c80e2bb6eeff39e31126b">如果想更新到最新预览版：</div><div class="notion-text notion-block-31cb48bfea2c80609303ebe6ae5c974f">更新完成建议重启 WSL：</div><hr class="notion-hr notion-block-31cb48bfea2c80c3b339c09a5247dd44"/><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-31cb48bfea2c80ff9ec4e3e3f9820834" data-id="31cb48bfea2c80ff9ec4e3e3f9820834"><span><div id="31cb48bfea2c80ff9ec4e3e3f9820834" class="notion-header-anchor"></div><a class="notion-hash-link" href="#31cb48bfea2c80ff9ec4e3e3f9820834" title="二、更新 WSL 里的 Linux 系统"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">二、更新 WSL 里的 Linux 系统</span></span></h2><div class="notion-text notion-block-31cb48bfea2c80cba6acce2ede2187dd">进入你的发行版，例如 Ubuntu：</div><div class="notion-text notion-block-31cb48bfea2c80a2ac3ff78d751d9c92">或者</div><div class="notion-text notion-block-31cb48bfea2c8000b70df0b47805ec4c">然后执行：</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-31cb48bfea2c8042a9e4f48075c8f4b6" data-id="31cb48bfea2c8042a9e4f48075c8f4b6"><span><div id="31cb48bfea2c8042a9e4f48075c8f4b6" class="notion-header-anchor"></div><a class="notion-hash-link" href="#31cb48bfea2c8042a9e4f48075c8f4b6" title="Ubuntu / Debian"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Ubuntu / Debian</span></span></h4><div class="notion-text notion-block-31cb48bfea2c8084a1e2cd1de7592789">如果想完整升级：</div><div class="notion-text notion-block-31cb48bfea2c807db35dedfc051e3870">清理无用包：</div><hr class="notion-hr notion-block-31cb48bfea2c80108a4ce289aa1a530a"/><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-31cb48bfea2c80e5b70af95eac53a14d" data-id="31cb48bfea2c80e5b70af95eac53a14d"><span><div id="31cb48bfea2c80e5b70af95eac53a14d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#31cb48bfea2c80e5b70af95eac53a14d" title="三、更新 WSL 的发行版版本（例如 Ubuntu 20 → 22）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">三、更新 WSL 的发行版版本（例如 Ubuntu 20 → 22）</span></span></h2><div class="notion-text notion-block-31cb48bfea2c8095b754d65b62786cae">如果你想升级 Linux 版本：</div><hr class="notion-hr notion-block-31cb48bfea2c809b92d7ea0531bcbeaa"/><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-31cb48bfea2c80388df4f2c7943ce574" data-id="31cb48bfea2c80388df4f2c7943ce574"><span><div id="31cb48bfea2c80388df4f2c7943ce574" class="notion-header-anchor"></div><a class="notion-hash-link" href="#31cb48bfea2c80388df4f2c7943ce574" title="四、检查 WSL 版本（WSL1 / WSL2）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">四、检查 WSL 版本（WSL1 / WSL2）</span></span></h2><div class="notion-text notion-block-31cb48bfea2c8034bb18d9f7fc7e1d2c">示例：</div><div class="notion-text notion-block-31cb48bfea2c80c7a404c7abf0a38dcd">如果想升级到 WSL2：</div><hr class="notion-hr notion-block-31cb48bfea2c809facb9e6013dc02f14"/><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-31cb48bfea2c80f7b490faa1ba32484a" data-id="31cb48bfea2c80f7b490faa1ba32484a"><span><div id="31cb48bfea2c80f7b490faa1ba32484a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#31cb48bfea2c80f7b490faa1ba32484a" title="五、一键推荐更新流程"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">五、一键推荐更新流程</span></span></h2><div class="notion-text notion-block-31cb48bfea2c80c5a5e7d6a4be73ad96">我自己一般这样更新：</div><hr class="notion-hr notion-block-31cb48bfea2c8029b2b3d1f30f559536"/><div class="notion-text notion-block-31cb48bfea2c808b889fe2bb0fd29c61">💡 如果你愿意，我可以再教你几个 <b>WSL 非常实用的维护命令</b>，比如：</div><ul class="notion-list notion-list-disc notion-block-31cb48bfea2c8092aeabd77a27a46e35"><li>一键备份 WSL</li></ul><ul class="notion-list notion-list-disc notion-block-31cb48bfea2c806f8470fa7f3f11e684"><li>重置 WSL</li></ul><ul class="notion-list notion-list-disc notion-block-31cb48bfea2c8018913de39df1a8b222"><li>迁移 WSL 到其他磁盘</li></ul><ul class="notion-list notion-list-disc notion-block-31cb48bfea2c8025bdeecb1c06f98813"><li>修复 WSL 卡死</li></ul><div class="notion-text notion-block-31cb48bfea2c8037b31cf2bf95abb87f">这些是很多人不知道但非常有用的技巧。</div><div class="notion-blank notion-block-31cb48bfea2c80de9503ef6b9242de3c"> </div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[蓝桥杯-二维动态规划]]></title>
            <link>https://blog.cpunull.me/article/Lanqiao Cup – Two-Dimensional Dynamic Programming</link>
            <guid>https://blog.cpunull.me/article/Lanqiao Cup – Two-Dimensional Dynamic Programming</guid>
            <pubDate>Sun, 01 Mar 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[蓝桥杯-二维动态规划]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-316b48bfea2c80dba13ef044b06eb578"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-316b48bfea2c800db874d984cb08e0cb"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Aad3aecc0-ba8b-4a3a-80ff-fe698a8bf2e9%3Aimage.png?table=block&amp;id=316b48bf-ea2c-800d-b874-d984cb08e0cb&amp;t=316b48bf-ea2c-800d-b874-d984cb08e0cb" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-table-of-contents notion-block-b7f3e536882e470796bf3d4df03dca5a"><a href="#7db93f61b26b4a3f8dd48af3fa2658a6" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">题目描述</span></a><a href="#fda828f439904974aa6be646e92a9f09" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">游戏规则</span></a><a href="#b4589d86d8fa433faaf6e044b55bd9ab" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">示例</span></a><a href="#58119832a46e4a4d8423fa30a24ab702" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">思路分析</span></a><a href="#84b7339f0f72403e8ec4f372d5d14343" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">为什么是二维动态规划</span></a><a href="#fe1bee3e799b4a28ad9defa5b09e484a" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">状态设计</span></a><a href="#782d27baab5f493eb293b615cbd979e0" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">状态转移</span></a><a href="#be5e09a2f62d4dbbb5d66dd25daf6578" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">初始状态</span></a><a href="#13baba53e7b34863b35b7da7e684b48a" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">最终答案</span></a><a href="#7f2f7c945238449ba274f89e35098e87" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">手动推导示例</span></a><a href="#baf0b58f0f4c4c47bf7056a7afa9903a" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">完整代码</span></a><a href="#3bc2226dbaf1415f8d60fb8653ab0790" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">代码说明</span></a><a href="#5f447279fe434bae96ed3018fab93912" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">1. dp 数组含义</span></a><a href="#831fe579cc584015ab7957a9264c729f" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">2. 初始化</span></a><a href="#50d0c0cde2e3472eb0cf63410b11fd35" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">3. 状态转移</span></a><a href="#8c837796f2984dc58015e5cafea3b7f3" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">复杂度分析</span></a><a href="#bafc89fee19347bb883946c5e970e34a" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">同类题型总结</span></a><a href="#56d77f553a57480ebd1bb516751e9d2f" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">常见同类题</span></a><a href="#59e2d8c57dce46ecade918054be89613" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">通用套路</span></a><a href="#c979375d3aca4074b0979dfa2246dc96" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">总结</span></a></div><blockquote class="notion-quote notion-block-0b589908e89b41a3bdfda7caea0489b3"><div>这道题是蓝桥杯里非常典型的 <b>二维动态规划</b>：把“传球次数”和“当前位置”作为两个维度，状态模型可以直接写成 <code class="notion-inline-code">dp[步数][位置]</code>。</div></blockquote><hr class="notion-hr notion-block-1062abfa4a7742f4a34de2a5894f28c8"/><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-7db93f61b26b4a3f8dd48af3fa2658a6" data-id="7db93f61b26b4a3f8dd48af3fa2658a6"><span><div id="7db93f61b26b4a3f8dd48af3fa2658a6" class="notion-header-anchor"></div><a class="notion-hash-link" href="#7db93f61b26b4a3f8dd48af3fa2658a6" title="题目描述"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">题目描述</span></span></h3><div class="notion-text notion-block-8c0da01bbab045e29ce9d495315b4dc1">上体育课的时候，老师带着同学们一起做 <b>传球游戏</b>。</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-fda828f439904974aa6be646e92a9f09" data-id="fda828f439904974aa6be646e92a9f09"><span><div id="fda828f439904974aa6be646e92a9f09" class="notion-header-anchor"></div><a class="notion-hash-link" href="#fda828f439904974aa6be646e92a9f09" title="游戏规则"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">游戏规则</span></span></h4><ul class="notion-list notion-list-disc notion-block-264750a3f542487f9e9972d5c14527e6"><li><code class="notion-inline-code">n</code> 个同学站成一个 <b>圆圈</b></li></ul><ul class="notion-list notion-list-disc notion-block-7cbfb3d50ea8404fb7212b11e6445c6d"><li>小蛮一开始拿着球</li></ul><ul class="notion-list notion-list-disc notion-block-e9111d6144cc4d97a8a371972a8442a3"><li>每次只能把球传给 <b>左边或右边的同学</b></li></ul><ul class="notion-list notion-list-disc notion-block-61afd4165ce24748bd571a6e93c8d220"><li>一共传 <code class="notion-inline-code">m</code> 次</li></ul><ul class="notion-list notion-list-disc notion-block-8ebc4ba00440449e975bf978709942e7"><li>求 <b>球最后回到小蛮手里的方案数</b></li></ul><div class="notion-text notion-block-f2b88b5b82b64eceb9484d60efd1ce52">若接球顺序不同，则认为是不同方案。</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-b4589d86d8fa433faaf6e044b55bd9ab" data-id="b4589d86d8fa433faaf6e044b55bd9ab"><span><div id="b4589d86d8fa433faaf6e044b55bd9ab" class="notion-header-anchor"></div><a class="notion-hash-link" href="#b4589d86d8fa433faaf6e044b55bd9ab" title="示例"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">示例</span></span></h4><div class="notion-text notion-block-1626de40716145498aa13729aa8a33ac">可行方案：</div><div class="notion-text notion-block-2764c5f1a4f444578f435b1f6960aabe">答案为：</div><hr class="notion-hr notion-block-4edc08ce8c0f46b8874e66b7dd46cb67"/><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-58119832a46e4a4d8423fa30a24ab702" data-id="58119832a46e4a4d8423fa30a24ab702"><span><div id="58119832a46e4a4d8423fa30a24ab702" class="notion-header-anchor"></div><a class="notion-hash-link" href="#58119832a46e4a4d8423fa30a24ab702" title="思路分析"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">思路分析</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-84b7339f0f72403e8ec4f372d5d14343" data-id="84b7339f0f72403e8ec4f372d5d14343"><span><div id="84b7339f0f72403e8ec4f372d5d14343" class="notion-header-anchor"></div><a class="notion-hash-link" href="#84b7339f0f72403e8ec4f372d5d14343" title="为什么是二维动态规划"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">为什么是二维动态规划</span></span></h4><div class="notion-text notion-block-e7e815ee2ae44ed3ac16bbec2b9fef35">题目里有几个非常明显的动态规划信号：</div><ul class="notion-list notion-list-disc notion-block-734c1980d37a4df7a4f9c2d81377bd69"><li>传了多少次</li></ul><ul class="notion-list notion-list-disc notion-block-31f40ffe788e44bdbf399ae9072c65fd"><li>当前球在谁手里</li></ul><ul class="notion-list notion-list-disc notion-block-43f425fa01f54619a5daa53abdd0c509"><li>每一步只能从相邻状态转移</li></ul><ul class="notion-list notion-list-disc notion-block-a84298f18af34598b9825cb7eaf89548"><li>最终要求统计方案数</li></ul><div class="notion-callout notion-blue_background_co notion-block-345a4990babd4955af75f48d39f6153c"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="💡">💡</span></div><div class="notion-callout-text"><div class="notion-text notion-block-5ce3de5b442b43a9b0131a91f42a4b25"><b>核心观察</b></div><ul class="notion-list notion-list-disc notion-block-751cef318dbe4875b3dcc1a093d4ead7"><li>一个状态必须同时记录：<b>传球次数</b> 和 <b>球所在的位置</b></li></ul><ul class="notion-list notion-list-disc notion-block-c100805422704a078ecc748eb56bd909"><li>因此这不是一维 DP，而是标准的二维 DP</li></ul><ul class="notion-list notion-list-disc notion-block-b512a0c42e724682b6bdfea80bc4655c"><li>常见模型就是：<code class="notion-inline-code">dp[步数][位置]</code></li></ul></div></div><hr class="notion-hr notion-block-e0be8b14c2a148e582e66e42337d3095"/><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-fe1bee3e799b4a28ad9defa5b09e484a" data-id="fe1bee3e799b4a28ad9defa5b09e484a"><span><div id="fe1bee3e799b4a28ad9defa5b09e484a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#fe1bee3e799b4a28ad9defa5b09e484a" title="状态设计"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">状态设计</span></span></h3><div class="notion-text notion-block-fe94a8a903b348719986c252374604a8">定义：</div><div class="notion-text notion-block-198b4293f83b47d698c8ce1b60a1544c">表示：</div><div class="notion-text notion-block-ba5ee9abe35e482d83ce9fa2d734fa39">为了方便处理圆环，编号统一设为：</div><div class="notion-text notion-block-42402b4eeac649e4a9594e3fe6d77029">其中：</div><hr class="notion-hr notion-block-91af81a870284e7c8b8034042163ab70"/><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-782d27baab5f493eb293b615cbd979e0" data-id="782d27baab5f493eb293b615cbd979e0"><span><div id="782d27baab5f493eb293b615cbd979e0" class="notion-header-anchor"></div><a class="notion-hash-link" href="#782d27baab5f493eb293b615cbd979e0" title="状态转移"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">状态转移</span></span></h3><div class="notion-text notion-block-804acf6613004adfb79a623c64f4af45">如果第 <code class="notion-inline-code">i</code> 次传球结束后，球在 <code class="notion-inline-code">j</code> 号同学手里，那么上一次一定来自：</div><ul class="notion-list notion-list-disc notion-block-00ca6d957271427eaa23eb46742bf7f7"><li><code class="notion-inline-code">j</code> 左边的同学</li></ul><ul class="notion-list notion-list-disc notion-block-996a7ca41b39411ba64a474717a0fb10"><li><code class="notion-inline-code">j</code> 右边的同学</li></ul><div class="notion-text notion-block-d73c0f9bb5d3467893e1d5633558dbd7">因此状态转移为：</div><div class="notion-text notion-block-ef8f08aa7ad94c6eb0e9c5cac358f08c">其中：</div><div class="notion-text notion-block-db4658b2bf6944bc80a6a732f6c2f10f">由于是环形结构，所以用取模来处理首尾相连。</div><hr class="notion-hr notion-block-5af4c7f82e03492488275a431cb68bab"/><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-be5e09a2f62d4dbbb5d66dd25daf6578" data-id="be5e09a2f62d4dbbb5d66dd25daf6578"><span><div id="be5e09a2f62d4dbbb5d66dd25daf6578" class="notion-header-anchor"></div><a class="notion-hash-link" href="#be5e09a2f62d4dbbb5d66dd25daf6578" title="初始状态"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">初始状态</span></span></h3><div class="notion-text notion-block-854521e68c0e4bcc9b13a52b8980b966">一开始球就在小蛮手里，所以：</div><div class="notion-text notion-block-9ae562296c9348d68bf0f3d7bb4a66fe">其余位置都不可能拿到球：</div><hr class="notion-hr notion-block-7a57b68118d04353ad2eece4c90a265c"/><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-13baba53e7b34863b35b7da7e684b48a" data-id="13baba53e7b34863b35b7da7e684b48a"><span><div id="13baba53e7b34863b35b7da7e684b48a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#13baba53e7b34863b35b7da7e684b48a" title="最终答案"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">最终答案</span></span></h3><div class="notion-text notion-block-d119de3daa73445aac2cd997b4171676">题目要求的是：</div><div class="notion-text notion-block-21884b6f55d54282ae4257737ef0e073">因此最终答案就是：</div><hr class="notion-hr notion-block-3902ecab02544938be8c8386a1e21fdf"/><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-7f2f7c945238449ba274f89e35098e87" data-id="7f2f7c945238449ba274f89e35098e87"><span><div id="7f2f7c945238449ba274f89e35098e87" class="notion-header-anchor"></div><a class="notion-hash-link" href="#7f2f7c945238449ba274f89e35098e87" title="手动推导示例"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">手动推导示例</span></span></h3><div class="notion-text notion-block-eb7f6fd69c2d47428161ad941d52800d">以 <code class="notion-inline-code">n = 3, m = 3</code> 为例：</div><ul class="notion-list notion-list-disc notion-block-5b8c7b96134d48a883c38cebf2beaa7f"><li>第 <code class="notion-inline-code">0</code> 次传球后：球在 <code class="notion-inline-code">0</code> 号手里</li></ul><ul class="notion-list notion-list-disc notion-block-d96242b3696f4e4b93b218eb0caa42ad"><li>第 <code class="notion-inline-code">1</code> 次传球后：球可能在 <code class="notion-inline-code">1</code> 或 <code class="notion-inline-code">2</code></li></ul><ul class="notion-list notion-list-disc notion-block-08e1817e05284afd830256416eb8ce57"><li>第 <code class="notion-inline-code">2</code> 次传球后：球继续在环上左右传播</li></ul><ul class="notion-list notion-list-disc notion-block-69af7f3955324a2899f268ff34104b3b"><li>第 <code class="notion-inline-code">3</code> 次传球后：回到 <code class="notion-inline-code">0</code> 号的方案一共有 <code class="notion-inline-code">2</code> 种</li></ul><div class="notion-text notion-block-eb4ee584a3394889a06aa587972458f3">对应路径就是：</div><div class="notion-text notion-block-c0dd4953eae34ebda70f2479b5d91f8b">这也验证了转移方程的正确性。</div><hr class="notion-hr notion-block-03268ec291704eaf86ff9180e49bcd20"/><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-baf0b58f0f4c4c47bf7056a7afa9903a" data-id="baf0b58f0f4c4c47bf7056a7afa9903a"><span><div id="baf0b58f0f4c4c47bf7056a7afa9903a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#baf0b58f0f4c4c47bf7056a7afa9903a" title="完整代码"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">完整代码</span></span></h3><hr class="notion-hr notion-block-259706412eae4979afc395d8868b7af6"/><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-3bc2226dbaf1415f8d60fb8653ab0790" data-id="3bc2226dbaf1415f8d60fb8653ab0790"><span><div id="3bc2226dbaf1415f8d60fb8653ab0790" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3bc2226dbaf1415f8d60fb8653ab0790" title="代码说明"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">代码说明</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-5f447279fe434bae96ed3018fab93912" data-id="5f447279fe434bae96ed3018fab93912"><span><div id="5f447279fe434bae96ed3018fab93912" class="notion-header-anchor"></div><a class="notion-hash-link" href="#5f447279fe434bae96ed3018fab93912" title="1. dp 数组含义"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">1. <code class="notion-inline-code">dp</code> 数组含义</span></span></h4><ul class="notion-list notion-list-disc notion-block-66d42ee4a4044b48a5f81a8108587744"><li>第一维表示传球次数</li></ul><ul class="notion-list notion-list-disc notion-block-557bb2bbdfbf4ef3a2647968ccbae459"><li>第二维表示当前球所在同学编号</li></ul><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-831fe579cc584015ab7957a9264c729f" data-id="831fe579cc584015ab7957a9264c729f"><span><div id="831fe579cc584015ab7957a9264c729f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#831fe579cc584015ab7957a9264c729f" title="2. 初始化"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2. 初始化</span></span></h4><div class="notion-text notion-block-bcd204735ed54507b262651d8900f05c">表示一开始球就在小蛮手里，只有 <code class="notion-inline-code">1</code> 种情况。</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-50d0c0cde2e3472eb0cf63410b11fd35" data-id="50d0c0cde2e3472eb0cf63410b11fd35"><span><div id="50d0c0cde2e3472eb0cf63410b11fd35" class="notion-header-anchor"></div><a class="notion-hash-link" href="#50d0c0cde2e3472eb0cf63410b11fd35" title="3. 状态转移"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">3. 状态转移</span></span></h4><div class="notion-text notion-block-100626cb9275423d9e799e61e97d1b1e">这里是整道题的核心：</div><ul class="notion-list notion-list-disc notion-block-78c08a521f61454ba1b686518764cb85"><li>当前状态由上一层两个相邻位置转移而来</li></ul><ul class="notion-list notion-list-disc notion-block-7b0e20542b0e4b95b6bbcc6977c06270"><li>用 <code class="notion-inline-code">% n</code> 处理圆环首尾连接</li></ul><hr class="notion-hr notion-block-59591087b6444c38a163c1626cc1935b"/><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-8c837796f2984dc58015e5cafea3b7f3" data-id="8c837796f2984dc58015e5cafea3b7f3"><span><div id="8c837796f2984dc58015e5cafea3b7f3" class="notion-header-anchor"></div><a class="notion-hash-link" href="#8c837796f2984dc58015e5cafea3b7f3" title="复杂度分析"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">复杂度分析</span></span></h3><ul class="notion-list notion-list-disc notion-block-ce0ab45f1f284d94b71351fd5707019b"><li>状态总数：<code class="notion-inline-code">m × n</code></li></ul><ul class="notion-list notion-list-disc notion-block-d1835f627deb40d88c5b4b70d8f98b04"><li>时间复杂度：<code class="notion-inline-code">O(nm)</code></li></ul><ul class="notion-list notion-list-disc notion-block-39a1077a7313419497dc9dd9996721ef"><li>空间复杂度：<code class="notion-inline-code">O(nm)</code></li></ul><div class="notion-text notion-block-1b257915b7ea47838892aff581a2eef8">在这道题的数据范围内，这个复杂度完全足够。</div><hr class="notion-hr notion-block-30afe463f4da4864b181cd3ee5875b0d"/><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-bafc89fee19347bb883946c5e970e34a" data-id="bafc89fee19347bb883946c5e970e34a"><span><div id="bafc89fee19347bb883946c5e970e34a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#bafc89fee19347bb883946c5e970e34a" title="同类题型总结"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">同类题型总结</span></span></h3><div class="notion-text notion-block-7d2cc6b7748944ca84890304c3b505f4">这道题属于非常经典的 <b>“步数 + 位置 + 方案数”</b> 模型。</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-56d77f553a57480ebd1bb516751e9d2f" data-id="56d77f553a57480ebd1bb516751e9d2f"><span><div id="56d77f553a57480ebd1bb516751e9d2f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#56d77f553a57480ebd1bb516751e9d2f" title="常见同类题"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">常见同类题</span></span></h4><ul class="notion-list notion-list-disc notion-block-a544e7cb729c415db51bd377af9ddc63"><li>机器人走路</li></ul><ul class="notion-list notion-list-disc notion-block-2adbcb331684470b8a2cecb01736f993"><li>棋盘走法</li></ul><ul class="notion-list notion-list-disc notion-block-89887d54e2fb4d1f9f2c9edd0dd12348"><li>青蛙跳台阶</li></ul><ul class="notion-list notion-list-disc notion-block-8babf90923f04e108717ac076b532e2c"><li>环形路径</li></ul><ul class="notion-list notion-list-disc notion-block-9db936a4941e41b08224da9f1ebdebe0"><li>网格路径</li></ul><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-59e2d8c57dce46ecade918054be89613" data-id="59e2d8c57dce46ecade918054be89613"><span><div id="59e2d8c57dce46ecade918054be89613" class="notion-header-anchor"></div><a class="notion-hash-link" href="#59e2d8c57dce46ecade918054be89613" title="通用套路"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">通用套路</span></span></h4><div class="notion-text notion-block-6b23f2db9b604771bd0a36bb2d7061c6">然后根据 <b>上一层状态</b> 来完成转移。</div><hr class="notion-hr notion-block-34b6259b4cf149fc9b07d34c5dd2bd51"/><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-c979375d3aca4074b0979dfa2246dc96" data-id="c979375d3aca4074b0979dfa2246dc96"><span><div id="c979375d3aca4074b0979dfa2246dc96" class="notion-header-anchor"></div><a class="notion-hash-link" href="#c979375d3aca4074b0979dfa2246dc96" title="总结"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">总结</span></span></h3><div class="notion-callout notion-teal_background_co notion-block-0a1a0b1d677e4175bef72065fa904959"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="✅">✅</span></div><div class="notion-callout-text"><div class="notion-text notion-block-ea7f068d6f2f44f0a252e2673f30ccf2"><b>这题的关键点</b></div><ol start="1" class="notion-list notion-list-numbered notion-block-5fdb43721e41488d9dc68d1508778ee7" style="list-style-type:decimal"><li><b>圆环结构</b> 要用取模处理左右邻居</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-a61f892001274bb6af807987e7b6a848" style="list-style-type:decimal"><li><b>状态必须开二维</b>：传球次数 + 所在位置</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-e908503367534b5cbe691812fa1a7c78" style="list-style-type:decimal"><li><b>本质是方案数 DP</b>，不是最值 DP</li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-6218f9b792b2404bbcc5b332883d6993" style="list-style-type:decimal"><li>蓝桥杯里只要看到“走几步 / 传几次 / 到某位置 / 求方案数”，优先联想到：<code class="notion-inline-code">dp[步数][位置]</code></li></ol></div></div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-31bb48bfea2c80308dc7cdaa7bac13bb"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A50034be3-c802-401b-8cc5-b889d2c7d357%3Aimage.png?table=block&amp;id=31bb48bf-ea2c-8030-8dc7-cdaa7bac13bb&amp;t=31bb48bf-ea2c-8030-8dc7-cdaa7bac13bb" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-31bb48bfea2c80aca05dc9e263d99e29"> </div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Google Banana画卡通信息图]]></title>
            <link>https://blog.cpunull.me/article/google-banana-draw-picture</link>
            <guid>https://blog.cpunull.me/article/google-banana-draw-picture</guid>
            <pubDate>Fri, 06 Mar 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[Google Banana画卡通信息图]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-31bb48bfea2c80a7a325c79bab6a772b"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-text notion-block-31bb48bfea2c80a8a1caea316bebc53c">提示词：</div><div class="notion-text notion-block-31bb48bfea2c809d893fce4eefc8b298">效果:</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-31bb48bfea2c80a8b1a2e054037c172d"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Ac0159b0c-397e-4107-ac50-32b6b6c91177%3Aimage.png?table=block&amp;id=31bb48bf-ea2c-80a8-b1a2-e054037c172d&amp;t=31bb48bf-ea2c-80a8-b1a2-e054037c172d" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-31bb48bfea2c80298de5ee969fd2a7eb"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Aff6d17b5-21ab-4e74-9704-adc312674b1b%3Af563d6c4510217775c1a3f89eff538bb.png?table=block&amp;id=31bb48bf-ea2c-8029-8de5-ee969fd2a7eb&amp;t=31bb48bf-ea2c-8029-8de5-ee969fd2a7eb" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-31bb48bfea2c80c0b0a4feb04b9035f4"> </div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[蓝桥杯-线性动态规划]]></title>
            <link>https://blog.cpunull.me/article/Lanqiao Cup - Linear Dynamic Programming</link>
            <guid>https://blog.cpunull.me/article/Lanqiao Cup - Linear Dynamic Programming</guid>
            <pubDate>Tue, 24 Feb 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[蓝桥杯-线性动态规划]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-311b48bfea2c803bb501f587431695d9"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-table-of-contents notion-block-b632606e8cf849fca874de3852330356"><a href="#1420176ffa3243c48ba8256ddcec962c" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">题目描述</span></a><a href="#612baf89aa38425bb5e91670eff9bb5a" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">思路分析</span></a><a href="#8fab6954d8d543fba26089d174a4b206" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">为什么不能用贪心？</span></a><a href="#07baf7e55c1c4a7fb6f3731d34306b6e" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">动态规划思路</span></a><a href="#b763fdb07e7b4f619a5e357c245edb0b" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">完整代码</span></a><a href="#a840d2120cf546c0ad3b23edfc59ce82" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">代码逐行解读</span></a><a href="#42410a582e3f4e74ba0286f27ef56f93" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">1. 初始化 dp 数组</span></a><a href="#97ed29732fb843ad85b927706d0b370a" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">2. 核心 DP 转移</span></a><a href="#190b80e6eaa14a789cf9ea4930092a2a" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">3. 查询输出</span></a><a href="#5a1b1349c962447e867ab244d042314d" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">手动模拟</span></a><a href="#80e682d50fba4d508c7b9d7cca1723a0" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">样例验证</span></a><a href="#798a9fbe405d4f669475318a708cc6ff" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">复杂度分析</span></a><a href="#a181285542af417dbee64a05facf5a8a" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">总结</span></a><a href="#8cac974d711c4622b8367fcab9703b7f" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">题目描述（二）：破损的楼梯</span></a><a href="#d949e7ea6de14eaba28a2dedf2dd9fd6" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">思路分析</span></a><a href="#2b09083097384d50b5192a023346f546" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">与经典爬楼梯问题的关系</span></a><a href="#2a0ccb11b7964b9881b41847a4c81df8" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">动态规划思路</span></a><a href="#755c8fd5eaf746dda4c8cda39af7c4fd" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">完整代码</span></a><a href="#f62314e859bf46ab9764bf05bbea7368" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">代码逐行解读</span></a><a href="#bc973def32034dbba30918b9724b477c" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">1. 初始化与标记破损台阶</span></a><a href="#42e498950c6442fbba0f02675736c766" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">2. 核心 DP 转移</span></a><a href="#d7d182762b7842378a023b80b2099b76" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">3. 输出结果</span></a><a href="#2d04c92b6ffc4c558998e1cf6269deb3" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">手动模拟</span></a><a href="#a30acdd629ab43d3b882ee547aa50e26" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">复杂度分析</span></a><a href="#1381eb0d783e42f184ea6787a4857c1f" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">总结</span></a></div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1420176ffa3243c48ba8256ddcec962c" data-id="1420176ffa3243c48ba8256ddcec962c"><span><div id="1420176ffa3243c48ba8256ddcec962c" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1420176ffa3243c48ba8256ddcec962c" title="题目描述"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">题目描述</span></span></h3><div class="notion-text notion-block-529bea4e55b84e758eed03573546b892">黄开的银行最近又发行了一种新面额的钞票，面值为 <b>4</b>，所以现在黄有 5 种面额的钞票，分别是 <b>20, 10, 5, 4, 1</b>。但是不变的是他小气，现在又有很多人来取钱，黄又不开心了，请你算出每个来取钱的人黄应该给他<b>至少多少张钞票</b>。</div><div class="notion-text notion-block-0962280b4ca54d408156369e663a8a26"><b>输入描述：</b> 每行输入一个正整数 n（1 ≤ n ≤ 10000），表示来取钱的金额。</div><div class="notion-text notion-block-a1fa5ea851734520b48d440f4e5380f5"><b>输出描述：</b> 每行输出一个整数，表示最少需要的钞票张数。</div><div class="notion-text notion-block-6585ace3ef4342978544e5f7ee1e2ed1"><b>样例输入：</b></div><div class="notion-text notion-block-81c96f08ea2a4add8dbea368b8015954"><b>样例输出：</b></div><hr class="notion-hr notion-block-398a7b03132944cd89181bddf697edb2"/><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-612baf89aa38425bb5e91670eff9bb5a" data-id="612baf89aa38425bb5e91670eff9bb5a"><span><div id="612baf89aa38425bb5e91670eff9bb5a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#612baf89aa38425bb5e91670eff9bb5a" title="思路分析"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">思路分析</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-8fab6954d8d543fba26089d174a4b206" data-id="8fab6954d8d543fba26089d174a4b206"><span><div id="8fab6954d8d543fba26089d174a4b206" class="notion-header-anchor"></div><a class="notion-hash-link" href="#8fab6954d8d543fba26089d174a4b206" title="为什么不能用贪心？"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">为什么不能用贪心？</span></span></h4><div class="notion-text notion-block-bdadad53f4b44ecc9d488375db3349e0">直觉上，每次尽量选最大面额即可。但面额 4 的引入破坏了贪心的正确性。</div><div class="notion-callout notion-yellow_background_co notion-block-2944098eeae947a6828ce6dd2ff0178c"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="⚠️">⚠️</span></div><div class="notion-callout-text"><div class="notion-text notion-block-eb017b571fc34a888e1f9510c44d89b3"><b>反例：n = 8</b></div><ul class="notion-list notion-list-disc notion-block-ec805a6d732346128e4963fe7b3d98c6"><li>贪心策略：5 + 1 + 1 + 1 = <b>4 张</b></li></ul><ul class="notion-list notion-list-disc notion-block-cb3fa17f3f9f4fb8b2784db76154d64b"><li>最优策略：4 + 4 = <b>2 张</b></li></ul><div class="notion-text notion-block-74cde451e10e476c8a55ed1ad0834bab">贪心不可行，必须使用<b>动态规划</b>。</div></div></div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-07baf7e55c1c4a7fb6f3731d34306b6e" data-id="07baf7e55c1c4a7fb6f3731d34306b6e"><span><div id="07baf7e55c1c4a7fb6f3731d34306b6e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#07baf7e55c1c4a7fb6f3731d34306b6e" title="动态规划思路"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">动态规划思路</span></span></h4><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-311b48bfea2c8010bb9fff9d3351f1c3"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Ab254d31d-65bf-41da-8486-5247fbd71bf5%3Aimage.png?table=block&amp;id=311b48bf-ea2c-8010-bb9f-ff9d3351f1c3&amp;t=311b48bf-ea2c-8010-bb9f-ff9d3351f1c3" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-3f00c105f44a4ec2a23ce2e11c8639af">这是一道经典的 <b>零钱兑换（Coin Change）</b> 问题，本质是 <b>完全背包</b> 的变体。</div><div class="notion-text notion-block-48f50c93b85a4ebd926e37ae7992831f"><b>状态定义：</b> <code class="notion-inline-code">dp[i]</code> 表示凑出金额 <code class="notion-inline-code">i</code> 所需的<b>最少钞票数</b>。</div><div class="notion-text notion-block-c6d6deff00e34f1dab50fb90be83c5e0"><b>状态转移方程：</b></div><div class="notion-text notion-block-137783cb32054aeda1d9b7fc300373f5">含义：要凑出金额 <code class="notion-inline-code">i</code>，可以选择用一张面额为 <code class="notion-inline-code">j</code> 的钞票，那么剩余金额 <code class="notion-inline-code">i - j</code> 需要 <code class="notion-inline-code">dp[i - j]</code> 张，加上当前这 1 张，取所有选择中的最小值。</div><div class="notion-text notion-block-0c5b021cf2d2423b931471c49b47f36d"><b>边界条件：</b> <code class="notion-inline-code">dp[0] = 0</code>（金额为 0 不需要钞票）</div><hr class="notion-hr notion-block-ca49625ab1e941b6b63f2c7ca9464a7a"/><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-b763fdb07e7b4f619a5e357c245edb0b" data-id="b763fdb07e7b4f619a5e357c245edb0b"><span><div id="b763fdb07e7b4f619a5e357c245edb0b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#b763fdb07e7b4f619a5e357c245edb0b" title="完整代码"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">完整代码</span></span></h3><hr class="notion-hr notion-block-233ebbedbce44df38fd9255dc9a7911c"/><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-a840d2120cf546c0ad3b23edfc59ce82" data-id="a840d2120cf546c0ad3b23edfc59ce82"><span><div id="a840d2120cf546c0ad3b23edfc59ce82" class="notion-header-anchor"></div><a class="notion-hash-link" href="#a840d2120cf546c0ad3b23edfc59ce82" title="代码逐行解读"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">代码逐行解读</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-42410a582e3f4e74ba0286f27ef56f93" data-id="42410a582e3f4e74ba0286f27ef56f93"><span><div id="42410a582e3f4e74ba0286f27ef56f93" class="notion-header-anchor"></div><a class="notion-hash-link" href="#42410a582e3f4e74ba0286f27ef56f93" title="1. 初始化 dp 数组"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">1. 初始化 dp 数组</span></span></h4><ul class="notion-list notion-list-disc notion-block-c6b3a395b6074577bfa919f7cd68d3f3"><li>开辟大小为 100001 的数组，覆盖所有可能的金额</li></ul><ul class="notion-list notion-list-disc notion-block-b356f670157a49f38f81afecc624e1b1"><li>全部填充为极大值 <code class="notion-inline-code">1e9</code>，表示&quot;尚未求解 / 凑不出&quot;</li></ul><ul class="notion-list notion-list-disc notion-block-345c64178dda4664b1c6e1e8099a3bd2"><li><code class="notion-inline-code">dp[0] = 0</code> 是递推的起点</li></ul><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-97ed29732fb843ad85b927706d0b370a" data-id="97ed29732fb843ad85b927706d0b370a"><span><div id="97ed29732fb843ad85b927706d0b370a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#97ed29732fb843ad85b927706d0b370a" title="2. 核心 DP 转移"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2. 核心 DP 转移</span></span></h4><div class="notion-text notion-block-7b9e87e64c8a462c9bb1e38071439c43">对于每个金额 <code class="notion-inline-code">i</code>，尝试用每一种面额 <code class="notion-inline-code">j</code>，取使得总张数最少的方案。</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-190b80e6eaa14a789cf9ea4930092a2a" data-id="190b80e6eaa14a789cf9ea4930092a2a"><span><div id="190b80e6eaa14a789cf9ea4930092a2a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#190b80e6eaa14a789cf9ea4930092a2a" title="3. 查询输出"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">3. 查询输出</span></span></h4><div class="notion-text notion-block-72e4d729b7344df28487c5b5dc3ac5f7">预处理完成后，每次查询 O(1) 直接读表。</div><hr class="notion-hr notion-block-3c77e63bc9b747d0a89ab59eb727c601"/><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-5a1b1349c962447e867ab244d042314d" data-id="5a1b1349c962447e867ab244d042314d"><span><div id="5a1b1349c962447e867ab244d042314d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#5a1b1349c962447e867ab244d042314d" title="手动模拟"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">手动模拟</span></span></h3><div class="notion-text notion-block-44f362b984b545c9a94cbaba7d7a95e3">以 <b>n = 8</b> 为例，展示 dp 表的构建过程：</div><table class="notion-simple-table notion-block-b4ef17e13af64928b6e90035ec564e5f"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-5d09f835874b4faf85bf0defa238c188"><td class="notion-simple-table-header-cell" style="width:120px"><div class="notion-simple-table-cell"><b>金额 i</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>尝试 j=1</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>尝试 j=4</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>尝试 j=5</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>dp[i] 结果</b></div></td></tr><tr class="notion-simple-table-row notion-block-47580f24845247a6ba1351e41aea7ef3"><td class="notion-simple-table-header-cell" style="width:120px"><div class="notion-simple-table-cell">0</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>0</b></div></td></tr><tr class="notion-simple-table-row notion-block-ef1bddaa4d1a484db44b7ced8ea617ab"><td class="notion-simple-table-header-cell" style="width:120px"><div class="notion-simple-table-cell">1</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">dp[0]+1=1</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>1</b></div></td></tr><tr class="notion-simple-table-row notion-block-7e5cde71cdf34b258162738a3b0fffe9"><td class="notion-simple-table-header-cell" style="width:120px"><div class="notion-simple-table-cell">2</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">dp[1]+1=2</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>2</b></div></td></tr><tr class="notion-simple-table-row notion-block-fbd467e5e90c48dd9e28d71954320330"><td class="notion-simple-table-header-cell" style="width:120px"><div class="notion-simple-table-cell">3</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">dp[2]+1=3</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>3</b></div></td></tr><tr class="notion-simple-table-row notion-block-4e567699702f4cee8f9d2d66db2ac2ca"><td class="notion-simple-table-header-cell" style="width:120px"><div class="notion-simple-table-cell">4</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">dp[3]+1=4</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">dp[0]+1=1</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>1</b></div></td></tr><tr class="notion-simple-table-row notion-block-85efaf0e43684ccdb78b2fa75a360172"><td class="notion-simple-table-header-cell" style="width:120px"><div class="notion-simple-table-cell">5</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">dp[4]+1=2</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">dp[1]+1=2</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">dp[0]+1=1</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>1</b></div></td></tr><tr class="notion-simple-table-row notion-block-c8b507eb0a394f9ebc80c65da5bc77e4"><td class="notion-simple-table-header-cell" style="width:120px"><div class="notion-simple-table-cell">6</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">dp[5]+1=2</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">dp[2]+1=3</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">dp[1]+1=2</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>2</b></div></td></tr><tr class="notion-simple-table-row notion-block-11ef69be562f49e1b9aaadd4803bc4cf"><td class="notion-simple-table-header-cell" style="width:120px"><div class="notion-simple-table-cell">7</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">dp[6]+1=3</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">dp[3]+1=4</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">dp[2]+1=3</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>3</b></div></td></tr><tr class="notion-simple-table-row notion-block-b0a6f0e5642d42d38dd2cd3a2db6d8a9"><td class="notion-simple-table-header-cell" style="width:120px"><div class="notion-simple-table-cell">8</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">dp[7]+1=4</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">dp[4]+1=2</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">dp[3]+1=4</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>2</b></div></td></tr></tbody></table><div class="notion-text notion-block-9b66ea6ba9214c2bb9f9080f837f6f66"><code class="notion-inline-code">dp[8] = 2</code>，对应方案：<b>4 + 4 = 8</b>（2 张），比贪心的 4 张更优。</div><hr class="notion-hr notion-block-325099b801234dfa8597b68bb3be7f5e"/><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-80e682d50fba4d508c7b9d7cca1723a0" data-id="80e682d50fba4d508c7b9d7cca1723a0"><span><div id="80e682d50fba4d508c7b9d7cca1723a0" class="notion-header-anchor"></div><a class="notion-hash-link" href="#80e682d50fba4d508c7b9d7cca1723a0" title="样例验证"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">样例验证</span></span></h3><ul class="notion-list notion-list-disc notion-block-1a4c7327fef94a748044f2f8eca5e6d8"><li><code class="notion-inline-code">dp[20]</code> = 1 → 一张 20 元</li></ul><ul class="notion-list notion-list-disc notion-block-5f30da2448854722ae448ceff3174a17"><li><code class="notion-inline-code">dp[2]</code> = 2 → 两张 1 元</li></ul><ul class="notion-list notion-list-disc notion-block-4a247f68c446412a8073a8cf2e6ec4d4"><li><code class="notion-inline-code">dp[6]</code> = 2 → 一张 5 元 + 一张 1 元</li></ul><div class="notion-text notion-block-1f2e532186df4084818ef89d0644c80f">输出 <code class="notion-inline-code">1, 2, 2</code>，与样例一致。</div><hr class="notion-hr notion-block-e10d498696b548dd9a07e601912727d5"/><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-798a9fbe405d4f669475318a708cc6ff" data-id="798a9fbe405d4f669475318a708cc6ff"><span><div id="798a9fbe405d4f669475318a708cc6ff" class="notion-header-anchor"></div><a class="notion-hash-link" href="#798a9fbe405d4f669475318a708cc6ff" title="复杂度分析"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">复杂度分析</span></span></h3><table class="notion-simple-table notion-block-8db7309d4074414083277ae439f94a2b"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-fc218f515a5443ebb726c0841e5994af"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>指标</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>复杂度</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>说明</b></div></td></tr><tr class="notion-simple-table-row notion-block-b52679dd0592486f9835bc6331ea3f5c"><td class="" style="width:120px"><div class="notion-simple-table-cell">时间复杂度</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">O(n × 5) = O(n)</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">预处理一次，每次查询 O(1)</div></td></tr><tr class="notion-simple-table-row notion-block-bff928a1c78b408b96ccff9124bcc013"><td class="" style="width:120px"><div class="notion-simple-table-cell">空间复杂度</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">O(n)</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">dp 数组大小与最大金额成正比</div></td></tr></tbody></table><hr class="notion-hr notion-block-5477a3345bdd47589dbe98586b88b050"/><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-a181285542af417dbee64a05facf5a8a" data-id="a181285542af417dbee64a05facf5a8a"><span><div id="a181285542af417dbee64a05facf5a8a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#a181285542af417dbee64a05facf5a8a" title="总结"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">总结</span></span></h3><div class="notion-callout notion-blue_background_co notion-block-d75e4a8cd75146709d6d85a1a6fcb5ae"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="💡">💡</span></div><div class="notion-callout-text"><div class="notion-text notion-block-eb5a34c7e1214bd98ede87c6bb826f43"><b>关键要点</b></div><ol start="1" class="notion-list notion-list-numbered notion-block-86af57ef3ae24a678d10f291eed90ecf" style="list-style-type:decimal"><li><b>贪心不可行</b> — 面额 4 的存在使得贪心策略可能得到非最优解</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-75e17af631f941208da91179a2bf80c3" style="list-style-type:decimal"><li><b>DP 预处理</b> — 一次性求解所有金额的最优解，查询时 O(1) 输出</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-db6988d838bd483b88c615de115de8fa" style="list-style-type:decimal"><li><b>本质</b> — 经典零钱兑换问题（LeetCode 322 Coin Change 变体），属于线性 DP</li></ol></div></div><div class="notion-blank notion-block-311b48bfea2c80bbbb47e3b7e6e74e58"> </div><hr class="notion-hr notion-block-b3663a37e01b4554bc82f2b1ba4e81a8"/><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-8cac974d711c4622b8367fcab9703b7f" data-id="8cac974d711c4622b8367fcab9703b7f"><span><div id="8cac974d711c4622b8367fcab9703b7f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#8cac974d711c4622b8367fcab9703b7f" title="题目描述（二）：破损的楼梯"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">题目描述（二）：破损的楼梯</span></span></h3><div class="notion-text notion-block-ae8802cd3d6949c68be6090d5bcfb0c6">小蓝来到了一座高耸的楼梯前，楼梯共有 <b>N</b> 级台阶，从第 <b>0</b> 级台阶出发。小蓝每次可以迈上 <b>1</b> 级或 <b>2</b> 级台阶。但是，楼梯上的第 a₁ 级、第 a₂ 级、第 a₃ 级……共 <b>M</b> 级台阶已经坏了，不能踩上去。</div><div class="notion-text notion-block-1d88ec53dbb84671890eb188e692cce5">现在，小蓝想要到达楼梯的顶端（第 <b>N</b> 级台阶），但他不能踩到坏了的台阶上。请问他有多少种不踩坏了的台阶到达顶端的方案数？由于方案数很大，请输出其对 <b>10⁹+7</b> 取模的结果。</div><div class="notion-text notion-block-c53d31da52f14ff3b820b21b047a361b"><b>输入格式：</b></div><ul class="notion-list notion-list-disc notion-block-6d8dcea3a81e45648272276bfaa7d781"><li>第一行包含两个正整数 N（1 ≤ N ≤ 10⁵）和 M（0 ≤ M ≤ N）</li></ul><ul class="notion-list notion-list-disc notion-block-3d08be1dd98d4900b9ab07de333ef6e9"><li>第二行包含 M 个正整数 a₁, a₂, …, aₘ（1 ≤ a₁ &lt; a₂ &lt; … &lt; aₘ ≤ N），表示坏掉的台阶编号</li></ul><div class="notion-text notion-block-362b9c934e2243f2ba59d26abe551818"><b>输出格式：</b> 输出一个整数，表示方案数对 10⁹+7 取模的结果。</div><div class="notion-text notion-block-caafda373edb430cb68fe14e1584ab39"><b>样例输入：</b></div><div class="notion-text notion-block-1f2a285f547d4981aebacb8c5e00ba6f"><b>样例输出：</b></div><hr class="notion-hr notion-block-3c74f5f3f9ba4f89a2a4b7cf3705e131"/><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-d949e7ea6de14eaba28a2dedf2dd9fd6" data-id="d949e7ea6de14eaba28a2dedf2dd9fd6"><span><div id="d949e7ea6de14eaba28a2dedf2dd9fd6" class="notion-header-anchor"></div><a class="notion-hash-link" href="#d949e7ea6de14eaba28a2dedf2dd9fd6" title="思路分析"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">思路分析</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-2b09083097384d50b5192a023346f546" data-id="2b09083097384d50b5192a023346f546"><span><div id="2b09083097384d50b5192a023346f546" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2b09083097384d50b5192a023346f546" title="与经典爬楼梯问题的关系"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">与经典爬楼梯问题的关系</span></span></h4><div class="notion-text notion-block-3b91b5c3e5f94b4c80cb18ed09aae630">这道题是经典 <b>爬楼梯（斐波那契）</b> 问题的变体。经典版本中，到达第 <code class="notion-inline-code">i</code> 级台阶的方案数等于到达第 <code class="notion-inline-code">i-1</code> 级与第 <code class="notion-inline-code">i-2</code> 级方案数之和：</div><div class="notion-callout notion-yellow_background_co notion-block-ceee1dcadfd64381a0bc92ce3efd35d3"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="⚠️">⚠️</span></div><div class="notion-callout-text"><div class="notion-text notion-block-a6890eb6ed6d43129b3127abda4f83ed"><b>新增约束：破损台阶</b></div><ul class="notion-list notion-list-disc notion-block-f8e4444d76c7417d8cbd82d082bd4251"><li>破损的台阶<b>不可踩踏</b>，因此 <code class="notion-inline-code">dp[broken] = 0</code>（方案数为 0）</li></ul><ul class="notion-list notion-list-disc notion-block-db718ff7195d425483234845681cce05"><li>从破损台阶出发的转移也需要<b>跳过</b>：只有 <code class="notion-inline-code">dp[i-1]</code> 和 <code class="notion-inline-code">dp[i-2]</code> 不是破损台阶时，才能将其方案数累加</li></ul></div></div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-2a0ccb11b7964b9881b41847a4c81df8" data-id="2a0ccb11b7964b9881b41847a4c81df8"><span><div id="2a0ccb11b7964b9881b41847a4c81df8" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2a0ccb11b7964b9881b41847a4c81df8" title="动态规划思路"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">动态规划思路</span></span></h4><div class="notion-text notion-block-53382a6176db4acfb408f8bee2c94081"><b>状态定义：</b> <code class="notion-inline-code">dp[i]</code> 表示从第 0 级台阶到达第 <code class="notion-inline-code">i</code> 级台阶的方案数。</div><div class="notion-text notion-block-e29f92f0ec7348e88dfc3181671d41e6"><b>状态转移方程：</b></div><div class="notion-text notion-block-08d8109d16174f8bb20f4e467debcb6b"><b>边界条件：</b> <code class="notion-inline-code">dp[0] = 1</code>（站在起点，有且仅有 1 种方案）</div><div class="notion-text notion-block-8e25595d9aec436cb109afbd1cad04f8"><b>取模：</b> 每一步累加后对 10⁹+7 取模，防止溢出。</div><hr class="notion-hr notion-block-d53d34f18a494369bea32c98277979cf"/><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-755c8fd5eaf746dda4c8cda39af7c4fd" data-id="755c8fd5eaf746dda4c8cda39af7c4fd"><span><div id="755c8fd5eaf746dda4c8cda39af7c4fd" class="notion-header-anchor"></div><a class="notion-hash-link" href="#755c8fd5eaf746dda4c8cda39af7c4fd" title="完整代码"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">完整代码</span></span></h3><hr class="notion-hr notion-block-d3fa63a127ef4523baade5abe5261c8e"/><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-f62314e859bf46ab9764bf05bbea7368" data-id="f62314e859bf46ab9764bf05bbea7368"><span><div id="f62314e859bf46ab9764bf05bbea7368" class="notion-header-anchor"></div><a class="notion-hash-link" href="#f62314e859bf46ab9764bf05bbea7368" title="代码逐行解读"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">代码逐行解读</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-bc973def32034dbba30918b9724b477c" data-id="bc973def32034dbba30918b9724b477c"><span><div id="bc973def32034dbba30918b9724b477c" class="notion-header-anchor"></div><a class="notion-hash-link" href="#bc973def32034dbba30918b9724b477c" title="1. 初始化与标记破损台阶"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">1. 初始化与标记破损台阶</span></span></h4><ul class="notion-list notion-list-disc notion-block-2d54e748253e4c69b9f7e90d94e1dbec"><li><code class="notion-inline-code">dp[0] = 1</code>：起点有 1 种方案（站在原地）</li></ul><ul class="notion-list notion-list-disc notion-block-e66deb4abe1346ad978c54f59c9f1135"><li>读入 M 个破损台阶编号，用 <code class="notion-inline-code">-1</code> 标记（与正常的方案数 <code class="notion-inline-code">0</code> 区分）</li></ul><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-42e498950c6442fbba0f02675736c766" data-id="42e498950c6442fbba0f02675736c766"><span><div id="42e498950c6442fbba0f02675736c766" class="notion-header-anchor"></div><a class="notion-hash-link" href="#42e498950c6442fbba0f02675736c766" title="2. 核心 DP 转移"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2. 核心 DP 转移</span></span></h4><ul class="notion-list notion-list-disc notion-block-d18b731a25f3465485c1f46deb2eecea"><li>遍历每一级台阶，跳过破损台阶</li></ul><ul class="notion-list notion-list-disc notion-block-666e4d873e574793a6515b3506c17125"><li>只从<b>非破损</b>的前驱台阶转移方案数</li></ul><ul class="notion-list notion-list-disc notion-block-ec24087b47fd407086691ee10c61f7b2"><li>每步取模防止溢出</li></ul><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-d7d182762b7842378a023b80b2099b76" data-id="d7d182762b7842378a023b80b2099b76"><span><div id="d7d182762b7842378a023b80b2099b76" class="notion-header-anchor"></div><a class="notion-hash-link" href="#d7d182762b7842378a023b80b2099b76" title="3. 输出结果"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">3. 输出结果</span></span></h4><ul class="notion-list notion-list-disc notion-block-5cab817d7c1b4c9eb98c16e08a4a74b4"><li>若终点本身破损，方案数为 0</li></ul><ul class="notion-list notion-list-disc notion-block-2ed9431542bf4213be2d99e97f0f891e"><li>否则输出 <code class="notion-inline-code">dp[n]</code></li></ul><hr class="notion-hr notion-block-df55b56d824d4eb7a56a8494ada47349"/><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-2d04c92b6ffc4c558998e1cf6269deb3" data-id="2d04c92b6ffc4c558998e1cf6269deb3"><span><div id="2d04c92b6ffc4c558998e1cf6269deb3" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2d04c92b6ffc4c558998e1cf6269deb3" title="手动模拟"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">手动模拟</span></span></h3><div class="notion-text notion-block-9c67a288167e49d6b5121d83b645227d">以 <b>N = 6, M = 1, 破损台阶 = {3}</b> 为例：</div><table class="notion-simple-table notion-block-1c07ea1055e64cc6b33fc0b22ba91018"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-9c30bf7cd0624c37aee1d031d54e0d24"><td class="notion-simple-table-header-cell" style="width:120px"><div class="notion-simple-table-cell"><b>台阶 i</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>是否破损</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>dp[i-1]</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>dp[i-2]</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>dp[i] 结果</b></div></td></tr><tr class="notion-simple-table-row notion-block-79fa69a132674c5d97361ba02077d619"><td class="notion-simple-table-header-cell" style="width:120px"><div class="notion-simple-table-cell">0</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">否</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>1</b>（初始值）</div></td></tr><tr class="notion-simple-table-row notion-block-465e71f5da744da6994c36ac05b506b4"><td class="notion-simple-table-header-cell" style="width:120px"><div class="notion-simple-table-cell">1</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">否</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">dp[0]=1</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>1</b></div></td></tr><tr class="notion-simple-table-row notion-block-555f5d9de85f4cbbbf6261b0eecb757f"><td class="notion-simple-table-header-cell" style="width:120px"><div class="notion-simple-table-cell">2</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">否</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">dp[1]=1</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">dp[0]=1</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>2</b></div></td></tr><tr class="notion-simple-table-row notion-block-35b0ca83cb4f4abb9f18d939505ffd5e"><td class="notion-simple-table-header-cell" style="width:120px"><div class="notion-simple-table-cell">3</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>是</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">跳过</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">跳过</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>-1</b>（破损）</div></td></tr><tr class="notion-simple-table-row notion-block-51cc9c9fa533403abb144a996e2452fa"><td class="notion-simple-table-header-cell" style="width:120px"><div class="notion-simple-table-cell">4</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">否</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">dp[3]=-1 跳过</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">dp[2]=2</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>2</b></div></td></tr><tr class="notion-simple-table-row notion-block-57a08d4955bf4f6395358e7cc4d34014"><td class="notion-simple-table-header-cell" style="width:120px"><div class="notion-simple-table-cell">5</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">否</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">dp[4]=2</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">dp[3]=-1 跳过</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>2</b></div></td></tr><tr class="notion-simple-table-row notion-block-fb609cca78e34c7899a62f4cf2bf61a1"><td class="notion-simple-table-header-cell" style="width:120px"><div class="notion-simple-table-cell">6</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">否</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">dp[5]=2</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">dp[4]=2</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>4</b></div></td></tr></tbody></table><div class="notion-text notion-block-8dc2c3b4004541588d6a7096a268d28d">最终 <code class="notion-inline-code">dp[6] = 4</code>，与样例输出一致。</div><hr class="notion-hr notion-block-764b132a9b994d9782051c8a69b840f0"/><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-a30acdd629ab43d3b882ee547aa50e26" data-id="a30acdd629ab43d3b882ee547aa50e26"><span><div id="a30acdd629ab43d3b882ee547aa50e26" class="notion-header-anchor"></div><a class="notion-hash-link" href="#a30acdd629ab43d3b882ee547aa50e26" title="复杂度分析"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">复杂度分析</span></span></h3><table class="notion-simple-table notion-block-ca6c4e189ca246d789cfee93d9ed373b"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-31c400d391b741239d42517b7c7521b7"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>指标</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>复杂度</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>说明</b></div></td></tr><tr class="notion-simple-table-row notion-block-35b37c25e4764b2097a7ae0e2d712cd8"><td class="" style="width:120px"><div class="notion-simple-table-cell">时间复杂度</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">O(N + M)</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">读入破损台阶 O(M)，DP 遍历 O(N)</div></td></tr><tr class="notion-simple-table-row notion-block-207505daa0c8408c96a3a295e6720ee2"><td class="" style="width:120px"><div class="notion-simple-table-cell">空间复杂度</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">O(N)</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">dp 数组大小与台阶数成正比</div></td></tr></tbody></table><hr class="notion-hr notion-block-8fac5ed5131c42719cc5892dc1fab43f"/><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1381eb0d783e42f184ea6787a4857c1f" data-id="1381eb0d783e42f184ea6787a4857c1f"><span><div id="1381eb0d783e42f184ea6787a4857c1f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1381eb0d783e42f184ea6787a4857c1f" title="总结"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">总结</span></span></h3><div class="notion-callout notion-blue_background_co notion-block-65618802822d4f87aae3fcf02ef99294"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="💡">💡</span></div><div class="notion-callout-text"><div class="notion-text notion-block-d774007617184ec39f764a032ea7c244"><b>关键要点</b></div><ol start="1" class="notion-list notion-list-numbered notion-block-5dcbb5805ccc4e5c91fe74167e0f6467" style="list-style-type:decimal"><li><b>经典爬楼梯的变体</b> — 在斐波那契递推基础上增加了&quot;不可达&quot;约束</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-0f86eb18150b445cb70290dd5efdbd29" style="list-style-type:decimal"><li><b>用 -1 标记破损台阶</b> — 巧妙地与方案数 0 区分，避免从破损台阶转移</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-ed1ea352a060457a83d79f23388551dd" style="list-style-type:decimal"><li><b>取模防溢出</b> — 每步对 10⁹+7 取模，确保结果在 int 范围内</li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-6aceb15bc4db4f9aae5421f01122256e" style="list-style-type:decimal"><li><b>本质</b> — 带障碍的线性 DP，类似 LeetCode 70（爬楼梯）+ LeetCode 746（最小花费爬楼梯）的组合变体</li></ol></div></div><div class="notion-blank notion-block-73c89c274f1740e89f585992bd9902a3"> </div></main></div>]]></content:encoded>
        </item>
    </channel>
</rss>