<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>tonakai0521のブログ</title>
<link>https://ameblo.jp/tonakai0521/</link>
<atom:link href="https://rssblog.ameba.jp/tonakai0521/rss20.xml" rel="self" type="application/rss+xml" />
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com" />
<description>AtCoderの解説を書いていきます。自分の理解力向上、復習がメインの目的ですが、読者のお役に立てたら嬉しいです。</description>
<language>ja</language>
<item>
<title>【解説】414 B AtCoder Beginner Contest</title>
<description>
<![CDATA[ <h2>AtCoder Beginner Contest 414B - String Too Long</h2><h3 data-end="227" data-start="159">解説</h3><div>答えとなる文字列をSとしてSに文字を追加していきます。</div><div>それと同時にその文字数をカウントしていきます。</div><div>&nbsp;</div><div>文字数が100を超えた時点でループをTooLongを出力してプログラムを終了します(exit())</div><div>&nbsp;</div><div>ループが最後までいけばSを出力します。</div><div>&nbsp;</div><div>&nbsp;</div><div>-------------------------------------------</div><div class="ogpCard_root">N = int(input())<br>cnt = 0<br>S = []<br>Q = []<br>for i in range(N):<br>&nbsp; &nbsp; c,l = input().split()<br>&nbsp; &nbsp; l = int(l)<br>&nbsp; &nbsp; Q.append([c,l])<br>for i in range(N):<br>&nbsp; &nbsp; c,l = Q[i][0],Q[i][1]<br>&nbsp; &nbsp; cnt += l<br>&nbsp; &nbsp; if cnt &gt; 100:<br>&nbsp; &nbsp; &nbsp; &nbsp; print("Too Long")<br>&nbsp; &nbsp; &nbsp; &nbsp; exit(0)<br>&nbsp; &nbsp; for j in range(l):<br>&nbsp; &nbsp; &nbsp; &nbsp; S.append(c)<br>print("".join(S))</div><p>&nbsp;</p><div class="ogpCard_root">&nbsp;</div><p>&nbsp;</p><div class="ogpCard_root"><div class="pickCreative_root" style="font-size:0"><article class="pickCreative_wrap" contenteditable="false" style="display:inline-block;max-width:100%"><a class="pickCreative pickLayout2" data-aid="8T2RJCq38qZRkzdz0cYq91" data-detail-setting="{&quot;show_price&quot;:false}" data-df-item-id="4297125218" data-img-size="medium" data-img-url="https://m.media-amazon.com/images/I/51Q+KKW3EyL._SL500_.jpg" data-item-id="AZ000001" data-layout-type="2" href="https://d.odsyms15.com/click?aid=8T2RJCq38qZRkzdz0cYq91" id="8T2RJCq38qZRkzdz0cYq91" style="background-color:#fff;border-radius:4px;box-sizing:border-box;display:block;max-width:100%;padding:4px 8px;text-decoration:none;width:450px;font-family:ヒラギノ角ゴ Pro W3, Hiragino Kaku Gothic Pro, ＭＳ Ｐゴシック, Helvetica, Arial, sans-serif;line-height:1;font-weight:normal;font-style:normal;word-break:break-all" target="_blank"><div class="pickLayout2_inner" style="display:flex"><div class="pickLayout2_info" style="flex:1 1 0%;overflow:hidden;min-width:56px"><div class="pickLayout2_title pickLayout2_title--medium" style="font-weight:bold;margin-bottom:8px;overflow:hidden;color:#333;text-align:left;white-space:normal;text-overflow:ellipsis;font-size:14px;line-height:1.3;max-height:3em;-webkit-box-orient:vertical;display:-webkit-box;-webkit-line-clamp:2;margin-top:19px">問題解決のための「アルゴリズム×数学」が基礎からしっかり身につく本</div><div class="pickLayout2_advertiser pickLayout2_advertiser--medium" style="font-size:10px;color:#757575;text-align:left;overflow:hidden;white-space:nowrap;text-overflow:ellipsis">Amazon（アマゾン）</div><div class="pickLayout2_price pickLayout2_price--medium" style="color:#333;text-align:left;font-size:14px;margin-top:12px;margin-bottom:12px">&nbsp;</div></div><div class="pickLayout2_imgWrapper pickLayout2_imgWrapper--medium" style="padding:4px 0;position:relative;margin-left:16px;width:144px;height:144px;flex-shrink:0"><img alt="" class="pickLayout2_img" data-img="affiliate" height="144" src="https://m.media-amazon.com/images/I/51Q+KKW3EyL._SL500_.jpg" style="width:auto;height:auto;margin:auto; margin: auto;position:absolute;top:0;left:0;right:0;bottom:0;max-width:100%;max-height:100%" width="144"></div></div></a><ul class="addShopLink_list" style="max-width:450px;padding:0;font-weight:bold;font-size:14px;font-family:Hiragino Kaku Gothic Pro;margin:0;list-style:none"><li class="addShopLink_listItem" style="display:block;width:100%;margin-top:8px"><a class="pickLink addShopLink_listItemLink" data-aid="3S05ThjpkOk1cJVRJA6VY2" data-df-item-id="4297125218" data-item-id="AZ000001" data-layout-type="101" href="https://d.odsyms15.com/click?aid=3S05ThjpkOk1cJVRJA6VY2" id="3S05ThjpkOk1cJVRJA6VY2" rel="noopener" style="display:flex;align-items:center;box-sizing:border-box;height:36px;padding:12px;padding-right:16px;color:#333;font-weight:bold;font-size:12px;text-decoration:none;background-color:#f8f8f8" target="_blank"><span class="addShopLink_listItemLinkShopName" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap">Amazon（アマゾン）</span><span class="addShopLink_listItemLinkShopMore" style="flex:1;word-break:keep-all;text-align:left">で詳細を見る</span><div class="addShopLink_listItemLinkArrow" style="display:inline-block;margin-left:auto;padding:5px;border-color:#757575;border-style:solid;border-top-width:0;border-right-width:2px;border-bottom-width:2px;border-left-width:0;transform:rotate(-45deg)"><div class="addShopLink_nothing" style="display:none">&nbsp;</div></div></a></li><li class="addShopLink_listItem" style="display:block;width:100%;margin-top:8px"><a class="pickLink addShopLink_listItemLink" data-aid="0kewL4UXxoObzPsvuYsRh5" data-df-item-id="azusa:10000143" data-item-id="RK000001" data-layout-type="101" href="https://d.odsyms15.com/click?aid=0kewL4UXxoObzPsvuYsRh5" id="0kewL4UXxoObzPsvuYsRh5" rel="noopener" style="display:flex;align-items:center;box-sizing:border-box;height:36px;padding:12px;padding-right:16px;color:#333;font-weight:bold;font-size:12px;text-decoration:none;background-color:#f8f8f8" target="_blank"><span class="addShopLink_listItemLinkShopName" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap">楽天市場</span><span class="addShopLink_listItemLinkShopMore" style="flex:1;word-break:keep-all;text-align:left">で詳細を見る</span><div data-eventlabel-end="1735570740" data-eventlabel-itemid="RK000001" data-eventlabel-start="1735484400" hidden style="background-color:#d91c0b;flex-shrink:0;font-size:10px;font-weight:bold;color:#fff;padding:4px 8px;border-radius:4px;margin:0 8px;box-sizing:border-box;width:-webkit-fit-content; width: -moz-fit-content; width: fit-content;line-height:1.2;max-width:5em;text-overflow:ellipsis;overflow:hidden;white-space:nowrap">${EVENT_LABEL_02_TEXT}</div><div class="addShopLink_listItemLinkArrow" style="display:inline-block;margin-left:auto;padding:5px;border-color:#757575;border-style:solid;border-top-width:0;border-right-width:2px;border-bottom-width:2px;border-left-width:0;transform:rotate(-45deg)"><div class="addShopLink_nothing" style="display:none">&nbsp;</div></div></a></li></ul></article></div><p>&nbsp;</p><div class="pickCreative_root" style="font-size:0"><article class="pickCreative_wrap" contenteditable="false" style="display:inline-block;max-width:100%"><a class="pickCreative pickLayout2" data-aid="enAF4BNc7YEUsc711SoC51" data-detail-setting="{&quot;show_price&quot;:false}" data-df-item-id="B0BDZGDM9J" data-img-size="medium" data-img-url="https://m.media-amazon.com/images/I/51g2fFApKBL._SL500_.jpg" data-item-id="AZ000001" data-layout-type="2" href="https://d.odsyms15.com/click?aid=enAF4BNc7YEUsc711SoC51" id="enAF4BNc7YEUsc711SoC51" style="background-color:#fff;border-radius:4px;box-sizing:border-box;display:block;max-width:100%;padding:4px 8px;text-decoration:none;width:450px;font-family:ヒラギノ角ゴ Pro W3, Hiragino Kaku Gothic Pro, ＭＳ Ｐゴシック, Helvetica, Arial, sans-serif;line-height:1;font-weight:normal;font-style:normal;word-break:break-all" target="_blank"><div class="pickLayout2_inner" style="display:flex"><div class="pickLayout2_info" style="flex:1 1 0%;overflow:hidden;min-width:56px"><div class="pickLayout2_title pickLayout2_title--medium" style="font-weight:bold;margin-bottom:8px;overflow:hidden;color:#333;text-align:left;white-space:normal;text-overflow:ellipsis;font-size:14px;line-height:1.3;max-height:3em;-webkit-box-orient:vertical;display:-webkit-box;-webkit-line-clamp:2;margin-top:19px">競技プログラミングの鉄則 (Compass Booksシリーズ)</div><div class="pickLayout2_advertiser pickLayout2_advertiser--medium" style="font-size:10px;color:#757575;text-align:left;overflow:hidden;white-space:nowrap;text-overflow:ellipsis">Amazon（アマゾン）</div><div class="pickLayout2_price pickLayout2_price--medium" style="color:#333;text-align:left;font-size:14px;margin-top:12px;margin-bottom:12px">&nbsp;</div></div><div class="pickLayout2_imgWrapper pickLayout2_imgWrapper--medium" style="padding:4px 0;position:relative;margin-left:16px;width:144px;height:144px;flex-shrink:0"><img alt="" class="pickLayout2_img" data-img="affiliate" height="144" src="https://m.media-amazon.com/images/I/51g2fFApKBL._SL500_.jpg" style="width:auto;height:auto;margin:auto; margin: auto;position:absolute;top:0;left:0;right:0;bottom:0;max-width:100%;max-height:100%" width="144"></div></div></a></article></div><p>&nbsp;</p></div><p>&nbsp;</p><p>&nbsp;</p><p><br>&nbsp;</p>
]]>
</description>
<link>https://ameblo.jp/tonakai0521/entry-12920455273.html</link>
<pubDate>Sun, 03 Aug 2025 10:47:14 +0900</pubDate>
</item>
<item>
<title>【解説】414 A AtCoder Beginner Contest</title>
<description>
<![CDATA[ <h2>AtCoder Beginner Contest 414A - Streamer Takahashi</h2><h3 data-end="227" data-start="159">解説</h3><div>題意を満たすための条件は下の２つです</div><div>&nbsp;</div><ol><li>&nbsp;L &gt;= x</li><li>y &gt;= R</li></ol><div>これを満たすパターンの数を数え上げていけば良いです。</div><div>&nbsp;</div><div>実際のコードは下のようになります。</div><div>&nbsp;</div><div>&nbsp;</div><div class="ogpCard_root">N,L,R = map(int,input().split())<br>ans = 0<br>for i in range(N):<br>&nbsp; &nbsp; x,y = map(int,input().split())<br>&nbsp; &nbsp; if x &lt;= L and R &lt;= y:<br>&nbsp; &nbsp; &nbsp; &nbsp; ans += 1<br>print(ans)</div><p>&nbsp;</p><div class="ogpCard_root">&nbsp;</div><p>&nbsp;</p><div class="ogpCard_root"><div class="pickCreative_root" style="font-size:0"><article class="pickCreative_wrap" contenteditable="false" style="display:inline-block;max-width:100%"><a class="pickCreative pickLayout2" data-aid="aU4zlcsgAXeGECRPr3s041" data-detail-setting="{&quot;show_price&quot;:false}" data-df-item-id="4297125218" data-img-size="medium" data-img-url="https://m.media-amazon.com/images/I/51Q+KKW3EyL._SL500_.jpg" data-item-id="AZ000001" data-layout-type="2" href="https://d.odsyms15.com/click?aid=aU4zlcsgAXeGECRPr3s041" id="aU4zlcsgAXeGECRPr3s041" style="background-color:#fff;border-radius:4px;box-sizing:border-box;display:block;max-width:100%;padding:4px 8px;text-decoration:none;width:450px;font-family:ヒラギノ角ゴ Pro W3, Hiragino Kaku Gothic Pro, ＭＳ Ｐゴシック, Helvetica, Arial, sans-serif;line-height:1;font-weight:normal;font-style:normal;word-break:break-all" target="_blank"><div class="pickLayout2_inner" style="display:flex"><div class="pickLayout2_info" style="flex:1 1 0%;overflow:hidden;min-width:56px"><div class="pickLayout2_title pickLayout2_title--medium" style="font-weight:bold;margin-bottom:8px;overflow:hidden;color:#333;text-align:left;white-space:normal;text-overflow:ellipsis;font-size:14px;line-height:1.3;max-height:3em;-webkit-box-orient:vertical;display:-webkit-box;-webkit-line-clamp:2;margin-top:19px">問題解決のための「アルゴリズム×数学」が基礎からしっかり身につく本</div><div class="pickLayout2_advertiser pickLayout2_advertiser--medium" style="font-size:10px;color:#757575;text-align:left;overflow:hidden;white-space:nowrap;text-overflow:ellipsis">Amazon（アマゾン）</div><div class="pickLayout2_price pickLayout2_price--medium" style="color:#333;text-align:left;font-size:14px;margin-top:12px;margin-bottom:12px">&nbsp;</div></div><div class="pickLayout2_imgWrapper pickLayout2_imgWrapper--medium" style="padding:4px 0;position:relative;margin-left:16px;width:144px;height:144px;flex-shrink:0"><img alt="" class="pickLayout2_img" data-img="affiliate" height="144" src="https://m.media-amazon.com/images/I/51Q+KKW3EyL._SL500_.jpg" style="width:auto;height:auto;margin:auto; margin: auto;position:absolute;top:0;left:0;right:0;bottom:0;max-width:100%;max-height:100%" width="144"></div></div></a><ul class="addShopLink_list" style="max-width:450px;padding:0;font-weight:bold;font-size:14px;font-family:Hiragino Kaku Gothic Pro;margin:0;list-style:none"><li class="addShopLink_listItem" style="display:block;width:100%;margin-top:8px"><a class="pickLink addShopLink_listItemLink" data-aid="7Ns2yJdIvqTV36Xgo637h4" data-df-item-id="4297125218" data-item-id="AZ000001" data-layout-type="101" href="https://d.odsyms15.com/click?aid=7Ns2yJdIvqTV36Xgo637h4" id="7Ns2yJdIvqTV36Xgo637h4" rel="noopener" style="display:flex;align-items:center;box-sizing:border-box;height:36px;padding:12px;padding-right:16px;color:#333;font-weight:bold;font-size:12px;text-decoration:none;background-color:#f8f8f8" target="_blank"><span class="addShopLink_listItemLinkShopName" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap">Amazon（アマゾン）</span><span class="addShopLink_listItemLinkShopMore" style="flex:1;word-break:keep-all;text-align:left">で詳細を見る</span><div class="addShopLink_listItemLinkArrow" style="display:inline-block;margin-left:auto;padding:5px;border-color:#757575;border-style:solid;border-top-width:0;border-right-width:2px;border-bottom-width:2px;border-left-width:0;transform:rotate(-45deg)"><div class="addShopLink_nothing" style="display:none">&nbsp;</div></div></a></li><li class="addShopLink_listItem" style="display:block;width:100%;margin-top:8px"><a class="pickLink addShopLink_listItemLink" data-aid="hgYdZAeAkJaqwWDJt0C3t2" data-df-item-id="azusa:10000143" data-item-id="RK000001" data-layout-type="101" href="https://d.odsyms15.com/click?aid=hgYdZAeAkJaqwWDJt0C3t2" id="hgYdZAeAkJaqwWDJt0C3t2" rel="noopener" style="display:flex;align-items:center;box-sizing:border-box;height:36px;padding:12px;padding-right:16px;color:#333;font-weight:bold;font-size:12px;text-decoration:none;background-color:#f8f8f8" target="_blank"><span class="addShopLink_listItemLinkShopName" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap">楽天市場</span><span class="addShopLink_listItemLinkShopMore" style="flex:1;word-break:keep-all;text-align:left">で詳細を見る</span><div data-eventlabel-end="1735570740" data-eventlabel-itemid="RK000001" data-eventlabel-start="1735484400" hidden style="background-color:#d91c0b;flex-shrink:0;font-size:10px;font-weight:bold;color:#fff;padding:4px 8px;border-radius:4px;margin:0 8px;box-sizing:border-box;width:-webkit-fit-content; width: -moz-fit-content; width: fit-content;line-height:1.2;max-width:5em;text-overflow:ellipsis;overflow:hidden;white-space:nowrap">${EVENT_LABEL_02_TEXT}</div><div class="addShopLink_listItemLinkArrow" style="display:inline-block;margin-left:auto;padding:5px;border-color:#757575;border-style:solid;border-top-width:0;border-right-width:2px;border-bottom-width:2px;border-left-width:0;transform:rotate(-45deg)"><div class="addShopLink_nothing" style="display:none">&nbsp;</div></div></a></li></ul></article></div><p>&nbsp;</p><div class="pickCreative_root" style="font-size:0"><article class="pickCreative_wrap" contenteditable="false" style="display:inline-block;max-width:100%"><a class="pickCreative pickLayout2" data-aid="vHs4z8AiMQfkM3J1Dd4WD1" data-detail-setting="{&quot;show_price&quot;:false}" data-df-item-id="B0BDZGDM9J" data-img-size="medium" data-img-url="https://m.media-amazon.com/images/I/51g2fFApKBL._SL500_.jpg" data-item-id="AZ000001" data-layout-type="2" href="https://d.odsyms15.com/click?aid=vHs4z8AiMQfkM3J1Dd4WD1" id="vHs4z8AiMQfkM3J1Dd4WD1" style="background-color:#fff;border-radius:4px;box-sizing:border-box;display:block;max-width:100%;padding:4px 8px;text-decoration:none;width:450px;font-family:ヒラギノ角ゴ Pro W3, Hiragino Kaku Gothic Pro, ＭＳ Ｐゴシック, Helvetica, Arial, sans-serif;line-height:1;font-weight:normal;font-style:normal;word-break:break-all" target="_blank"><div class="pickLayout2_inner" style="display:flex"><div class="pickLayout2_info" style="flex:1 1 0%;overflow:hidden;min-width:56px"><div class="pickLayout2_title pickLayout2_title--medium" style="font-weight:bold;margin-bottom:8px;overflow:hidden;color:#333;text-align:left;white-space:normal;text-overflow:ellipsis;font-size:14px;line-height:1.3;max-height:3em;-webkit-box-orient:vertical;display:-webkit-box;-webkit-line-clamp:2;margin-top:19px">競技プログラミングの鉄則 (Compass Booksシリーズ)</div><div class="pickLayout2_advertiser pickLayout2_advertiser--medium" style="font-size:10px;color:#757575;text-align:left;overflow:hidden;white-space:nowrap;text-overflow:ellipsis">Amazon（アマゾン）</div><div class="pickLayout2_price pickLayout2_price--medium" style="color:#333;text-align:left;font-size:14px;margin-top:12px;margin-bottom:12px">&nbsp;</div></div><div class="pickLayout2_imgWrapper pickLayout2_imgWrapper--medium" style="padding:4px 0;position:relative;margin-left:16px;width:144px;height:144px;flex-shrink:0"><img alt="" class="pickLayout2_img" data-img="affiliate" height="144" src="https://m.media-amazon.com/images/I/51g2fFApKBL._SL500_.jpg" style="width:auto;height:auto;margin:auto; margin: auto;position:absolute;top:0;left:0;right:0;bottom:0;max-width:100%;max-height:100%" width="144"></div></div></a></article></div><p>&nbsp;</p></div><p>&nbsp;</p><p>&nbsp;</p><p><br>&nbsp;</p>
]]>
</description>
<link>https://ameblo.jp/tonakai0521/entry-12920454698.html</link>
<pubDate>Sun, 03 Aug 2025 10:41:18 +0900</pubDate>
</item>
<item>
<title>【解説】413E AtCoder Beginner Contest</title>
<description>
<![CDATA[ <h2>AtCoder Beginner Contest 413 E - Reverse 2^i</h2><p>使用言語はPythonです。</p><h2 data-end="461" data-start="451">問題のポイント</h2><ul data-end="585" data-start="463"><li data-end="505" data-start="463"><p data-end="505" data-start="465">区間は長さが 2b2^b2b の連続部分であり、その区間を丸ごと反転できる。</p></li><li data-end="538" data-start="506"><p data-end="538" data-start="508">反転の単位は自由に選べるが、区間の長さは必ず2のべき乗。</p></li><li data-end="565" data-start="539"><p data-end="565" data-start="541">辞書順とは、順列を辞書式に並べたときの順番。</p></li><li data-end="585" data-start="566"><p data-end="585" data-start="568">操作回数制限はなく、0回でもOK。</p></li></ul><hr data-end="590" data-start="587"><h2 data-end="601" data-start="592">考え方のコツ</h2><ul data-end="722" data-start="603"><li data-end="628" data-start="603"><p data-end="628" data-start="605">NNN が大きくなると全探索は不可能。</p></li><li data-end="675" data-start="629"><p data-end="675" data-start="631">区間の反転をうまく利用して、部分列の辞書順を比較し、より小さい順序を選ぶ必要がある。</p></li><li data-end="722" data-start="676"><p data-end="722" data-start="678">再帰的に配列を半分に分けて比較し、必要なら左右の半分を反転させて並べ替える方法が効果的。</p></li></ul><hr data-end="727" data-start="724"><h2 data-end="738" data-start="729">コードの説明</h2><ul data-end="845" data-start="740"><li data-end="795" data-start="740"><p data-end="795" data-start="742"><code data-end="750" data-start="742">search</code>関数は渡されたリストを再帰的に半分に分割し、左右の最小値を比較して必要なら左右を反転。</p></li><li data-end="845" data-start="796"><p data-end="845" data-start="798">こうすることで部分列ごとに辞書順が小さくなるように整え、最終的に全体の辞書順最小を求める。</p></li></ul><hr data-end="850" data-start="847"><h2 data-end="859" data-start="852">コード例</h2><p data-end="879" data-start="861">T = int(input())</p><p data-end="1053" data-start="881">def search(lst):<br data-end="900" data-start="897"> b = len(lst)<br data-end="916" data-start="913"> if b == 1:<br data-end="930" data-start="927">  return lst<br data-end="945" data-start="942"> if min(lst[:b//2]) &gt; min(lst[b//2:]):<br data-end="986" data-start="983">  lst.reverse()<br data-end="1004" data-start="1001"> return search(lst[:b//2]) + search(lst[b//2:])</p><p data-end="1168" data-start="1055">for _ in range(T):<br data-end="1076" data-start="1073"> N = int(input())<br data-end="1096" data-start="1093"> P = list(map(int, input().split()))<br data-end="1135" data-start="1132"> ans = search(P)<br data-end="1154" data-start="1151"> print(*ans)</p><hr data-end="1173" data-start="1170"><h2 data-end="1181" data-start="1175">まとめ</h2><ul data-end="1288" data-start="1183"><li data-end="1210" data-start="1183"><p data-end="1210" data-start="1185">問題は区間反転を使って辞書順最小を目指すもの。</p></li><li data-end="1244" data-start="1211"><p data-end="1244" data-start="1213">再帰的に配列を左右に分けて比較し、反転を決める方法で解く。</p></li><li data-end="1288" data-start="1245"><p data-end="1288" data-start="1247">2N2^N2N のサイズの配列を半分に分ける操作を繰り返すことで効率的に解決可能。</p></li></ul><main id="main"><p>&nbsp;</p></main><div class="ogpCard_root"><div class="pickCreative_root" style="font-size:0"><article class="pickCreative_wrap" contenteditable="false" style="display:inline-block;max-width:100%"><a class="pickCreative pickLayout2" data-aid="Y3U3SylwPbGR8pQQAEgfC5" data-detail-setting="{&quot;show_price&quot;:false}" data-df-item-id="4297125218" data-img-size="medium" data-img-url="https://m.media-amazon.com/images/I/51Q+KKW3EyL._SL500_.jpg" data-item-id="AZ000001" data-layout-type="2" href="https://d.odsyms15.com/click?aid=Y3U3SylwPbGR8pQQAEgfC5" id="Y3U3SylwPbGR8pQQAEgfC5" style="background-color:#fff;border-radius:4px;box-sizing:border-box;display:block;max-width:100%;padding:4px 8px;text-decoration:none;width:450px;font-family:ヒラギノ角ゴ Pro W3, Hiragino Kaku Gothic Pro, ＭＳ Ｐゴシック, Helvetica, Arial, sans-serif;line-height:1;font-weight:normal;font-style:normal;word-break:break-all" target="_blank"><div class="pickLayout2_inner" style="display:flex"><div class="pickLayout2_info" style="flex:1 1 0%;overflow:hidden;min-width:56px"><div class="pickLayout2_title pickLayout2_title--medium" style="font-weight:bold;margin-bottom:8px;overflow:hidden;color:#333;text-align:left;white-space:normal;text-overflow:ellipsis;font-size:14px;line-height:1.3;max-height:3em;-webkit-box-orient:vertical;display:-webkit-box;-webkit-line-clamp:2;margin-top:19px">問題解決のための「アルゴリズム×数学」が基礎からしっかり身につく本</div><div class="pickLayout2_advertiser pickLayout2_advertiser--medium" style="font-size:10px;color:#757575;text-align:left;overflow:hidden;white-space:nowrap;text-overflow:ellipsis">Amazon（アマゾン）</div><div class="pickLayout2_price pickLayout2_price--medium" style="color:#333;text-align:left;font-size:14px;margin-top:12px;margin-bottom:12px">&nbsp;</div></div><div class="pickLayout2_imgWrapper pickLayout2_imgWrapper--medium" style="padding:4px 0;position:relative;margin-left:16px;width:144px;height:144px;flex-shrink:0"><img alt="" class="pickLayout2_img" data-img="affiliate" height="144" src="https://m.media-amazon.com/images/I/51Q+KKW3EyL._SL500_.jpg" style="width:auto;height:auto;margin:auto; margin: auto;position:absolute;top:0;left:0;right:0;bottom:0;max-width:100%;max-height:100%" width="144"></div></div></a><ul class="addShopLink_list" style="max-width:450px;padding:0;font-weight:bold;font-size:14px;font-family:Hiragino Kaku Gothic Pro;margin:0;list-style:none"><li class="addShopLink_listItem" style="display:block;width:100%;margin-top:8px"><a class="pickLink addShopLink_listItemLink" data-aid="BXi1i4ptrC4V7xD0Cjfe27" data-df-item-id="4297125218" data-item-id="AZ000001" data-layout-type="101" href="https://d.odsyms15.com/click?aid=BXi1i4ptrC4V7xD0Cjfe27" id="BXi1i4ptrC4V7xD0Cjfe27" rel="noopener" style="display:flex;align-items:center;box-sizing:border-box;height:36px;padding:12px;padding-right:16px;color:#333;font-weight:bold;font-size:12px;text-decoration:none;background-color:#f8f8f8" target="_blank"><span class="addShopLink_listItemLinkShopName" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap">Amazon（アマゾン）</span><span class="addShopLink_listItemLinkShopMore" style="flex:1;word-break:keep-all;text-align:left">で詳細を見る</span><div class="addShopLink_listItemLinkArrow" style="display:inline-block;margin-left:auto;padding:5px;border-color:#757575;border-style:solid;border-top-width:0;border-right-width:2px;border-bottom-width:2px;border-left-width:0;transform:rotate(-45deg)"><div class="addShopLink_nothing" style="display:none">&nbsp;</div></div></a></li><li class="addShopLink_listItem" style="display:block;width:100%;margin-top:8px"><a class="pickLink addShopLink_listItemLink" data-aid="7bdAKAb0UHxJNX4zCNaoq7" data-df-item-id="azusa:10000143" data-item-id="RK000001" data-layout-type="101" href="https://d.odsyms15.com/click?aid=7bdAKAb0UHxJNX4zCNaoq7" id="7bdAKAb0UHxJNX4zCNaoq7" rel="noopener" style="display:flex;align-items:center;box-sizing:border-box;height:36px;padding:12px;padding-right:16px;color:#333;font-weight:bold;font-size:12px;text-decoration:none;background-color:#f8f8f8" target="_blank"><span class="addShopLink_listItemLinkShopName" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap">楽天市場</span><span class="addShopLink_listItemLinkShopMore" style="flex:1;word-break:keep-all;text-align:left">で詳細を見る</span><div data-eventlabel-end="1735570740" data-eventlabel-itemid="RK000001" data-eventlabel-start="1735484400" hidden style="background-color:#d91c0b;flex-shrink:0;font-size:10px;font-weight:bold;color:#fff;padding:4px 8px;border-radius:4px;margin:0 8px;box-sizing:border-box;width:-webkit-fit-content; width: -moz-fit-content; width: fit-content;line-height:1.2;max-width:5em;text-overflow:ellipsis;overflow:hidden;white-space:nowrap">${EVENT_LABEL_02_TEXT}</div><div class="addShopLink_listItemLinkArrow" style="display:inline-block;margin-left:auto;padding:5px;border-color:#757575;border-style:solid;border-top-width:0;border-right-width:2px;border-bottom-width:2px;border-left-width:0;transform:rotate(-45deg)"><div class="addShopLink_nothing" style="display:none">&nbsp;</div></div></a></li></ul></article></div><p>&nbsp;</p><div class="pickCreative_root" style="font-size:0"><article class="pickCreative_wrap" contenteditable="false" style="display:inline-block;max-width:100%"><a class="pickCreative pickLayout2" data-aid="YvG7xArRXPMJXacW03Tdf4" data-detail-setting="{&quot;show_price&quot;:false}" data-df-item-id="B0BDZGDM9J" data-img-size="medium" data-img-url="https://m.media-amazon.com/images/I/51g2fFApKBL._SL500_.jpg" data-item-id="AZ000001" data-layout-type="2" href="https://d.odsyms15.com/click?aid=YvG7xArRXPMJXacW03Tdf4" id="YvG7xArRXPMJXacW03Tdf4" style="background-color:#fff;border-radius:4px;box-sizing:border-box;display:block;max-width:100%;padding:4px 8px;text-decoration:none;width:450px;font-family:ヒラギノ角ゴ Pro W3, Hiragino Kaku Gothic Pro, ＭＳ Ｐゴシック, Helvetica, Arial, sans-serif;line-height:1;font-weight:normal;font-style:normal;word-break:break-all" target="_blank"><div class="pickLayout2_inner" style="display:flex"><div class="pickLayout2_info" style="flex:1 1 0%;overflow:hidden;min-width:56px"><div class="pickLayout2_title pickLayout2_title--medium" style="font-weight:bold;margin-bottom:8px;overflow:hidden;color:#333;text-align:left;white-space:normal;text-overflow:ellipsis;font-size:14px;line-height:1.3;max-height:3em;-webkit-box-orient:vertical;display:-webkit-box;-webkit-line-clamp:2;margin-top:19px">競技プログラミングの鉄則 (Compass Booksシリーズ)</div><div class="pickLayout2_advertiser pickLayout2_advertiser--medium" style="font-size:10px;color:#757575;text-align:left;overflow:hidden;white-space:nowrap;text-overflow:ellipsis">Amazon（アマゾン）</div><div class="pickLayout2_price pickLayout2_price--medium" style="color:#333;text-align:left;font-size:14px;margin-top:12px;margin-bottom:12px">&nbsp;</div></div><div class="pickLayout2_imgWrapper pickLayout2_imgWrapper--medium" style="padding:4px 0;position:relative;margin-left:16px;width:144px;height:144px;flex-shrink:0"><img alt="" class="pickLayout2_img" data-img="affiliate" height="144" src="https://m.media-amazon.com/images/I/51g2fFApKBL._SL500_.jpg" style="width:auto;height:auto;margin:auto; margin: auto;position:absolute;top:0;left:0;right:0;bottom:0;max-width:100%;max-height:100%" width="144"></div></div></a></article></div><p>&nbsp;</p></div><p>&nbsp;</p><p>&nbsp;</p><p><br>&nbsp;</p>
]]>
</description>
<link>https://ameblo.jp/tonakai0521/entry-12914887093.html</link>
<pubDate>Sun, 06 Jul 2025 18:10:10 +0900</pubDate>
</item>
<item>
<title>【解説】413D AtCoder Beginner Contest</title>
<description>
<![CDATA[ <h2>AtCoder Beginner Contest 413 D - Make Geometric Sequence</h2><p>使用言語はPythonです。</p><h2 data-end="92" data-start="85">問題概要</h2><p data-end="156" data-start="94">長さ N の整数列 A=(A1, A2, ..., AN) が与えられます。<br data-end="135" data-start="132">全ての Ai は 0 ではありません。</p><p data-end="188" data-start="158">この数列を並べ替えて等比数列にできるか判定してください。</p><p data-end="252" data-start="190">等比数列とは、ある実数 r があって、すべての i について<br data-end="223" data-start="220">Bi+1 = r × Bi が成り立つ数列のことです。</p><hr data-end="257" data-start="254"><h2 data-end="270" data-start="259">解き方のポイント</h2><ul data-end="509" data-start="272"><li data-end="312" data-start="272"><p data-end="312" data-start="274">並べ替え可能なので、数列の順序を自由に変えて等比数列になれば「Yes」。</p></li><li data-end="333" data-start="313"><p data-end="333" data-start="315">N=2 の場合は必ず「Yes」。</p></li><li data-end="371" data-start="334"><p data-end="371" data-start="336">N ≥ 3 の場合は、まず絶対値で数列をソートして等比数列か判定。</p></li><li data-end="462" data-start="372"><p data-end="462" data-start="374">等比数列の判定は、隣接する3つの要素 B[j], B[j+1], B[j+2] が<br data-end="418" data-start="415">B[j+2] × B[j] = (B[j+1])² を満たすかでチェックできる。</p></li><li data-end="509" data-start="463"><p data-end="509" data-start="465">符号パターン（すべて正、すべて負、交互に正負など）も試し、元の数列と一致するか確認する。</p></li></ul><hr data-end="514" data-start="511"><h2 data-end="523" data-start="516">コード例</h2><p data-end="1304" data-start="525">T = int(input())<br data-end="544" data-start="541">ans = []<br data-end="555" data-start="552">for _ in range(T):<br data-end="576" data-start="573"> N = int(input())<br data-end="596" data-start="593"> A = list(map(int, input().split()))<br data-end="635" data-start="632"> A.sort()<br data-end="647" data-start="644"> B = []<br data-end="657" data-start="654"> if N == 2:<br data-end="671" data-start="668">  ans.append("Yes")<br data-end="693" data-start="690"> else:<br data-end="702" data-start="699">  for j in range(N):<br data-end="725" data-start="722">   B.append(abs(A[j]))<br data-end="750" data-start="747">  B.sort()<br data-end="763" data-start="760">  flag = True<br data-end="779" data-start="776">  for j in range(N - 2):<br data-end="806" data-start="803">   if B[j + 2] * B[j] != B[j + 1] ** 2:<br data-end="848" data-start="845">    flag = False<br data-end="867" data-start="864">  if not flag:<br data-end="884" data-start="881">   ans.append("No")<br data-end="906" data-start="903">  else:<br data-end="916" data-start="913">   C = []<br data-end="928" data-start="925">   D = []<br data-end="940" data-start="937">   E = []<br data-end="952" data-start="949">   for j in range(N):<br data-end="976" data-start="973">    C.append(-B[j])<br data-end="998" data-start="995">    if j % 2 == 0:<br data-end="1019" data-start="1016">     D.append(B[j])<br data-end="1041" data-start="1038">     E.append(-B[j])<br data-end="1064" data-start="1061">    else:<br data-end="1076" data-start="1073">     E.append(B[j])<br data-end="1098" data-start="1095">     D.append(-B[j])<br data-end="1121" data-start="1118">   C.sort()<br data-end="1135" data-start="1132">   D.sort()<br data-end="1149" data-start="1146">   E.sort()<br data-end="1163" data-start="1160">   if A == B or A == C or A == D or A == E:<br data-end="1209" data-start="1206">    ans.append("Yes")<br data-end="1233" data-start="1230">   else:<br data-end="1244" data-start="1241">    ans.append("No")<br data-end="1267" data-start="1264">for i in range(T):<br data-end="1288" data-start="1285"> print(ans[i])</p><hr data-end="1309" data-start="1306"><h2 data-end="1317" data-start="1311">まとめ</h2><ul data-end="1393" data-start="1319"><li data-end="1342" data-start="1319"><p data-end="1342" data-start="1321">数列の絶対値を使って等比数列か判定し、</p></li><li data-end="1376" data-start="1343"><p data-end="1376" data-start="1345">符号のパターンを複数試して元の配列と一致すれば「Yes」。</p></li><li data-end="1393" data-start="1377"><p data-end="1393" data-start="1379">そうでなければ「No」。</p></li></ul><p data-end="1426" data-start="1395">この問題の考え方は応用も利くので、ぜひ覚えておきましょう！</p><main id="main"><p>&nbsp;</p></main><div class="ogpCard_root"><div class="pickCreative_root" style="font-size:0"><article class="pickCreative_wrap" contenteditable="false" style="display:inline-block;max-width:100%"><a class="pickCreative pickLayout2" data-aid="0CN96yPzvNiewx4sEAnto1" data-detail-setting="{&quot;show_price&quot;:false}" data-df-item-id="4297125218" data-img-size="medium" data-img-url="https://m.media-amazon.com/images/I/51Q+KKW3EyL._SL500_.jpg" data-item-id="AZ000001" data-layout-type="2" href="https://d.odsyms15.com/click?aid=0CN96yPzvNiewx4sEAnto1" id="0CN96yPzvNiewx4sEAnto1" style="background-color:#fff;border-radius:4px;box-sizing:border-box;display:block;max-width:100%;padding:4px 8px;text-decoration:none;width:450px;font-family:ヒラギノ角ゴ Pro W3, Hiragino Kaku Gothic Pro, ＭＳ Ｐゴシック, Helvetica, Arial, sans-serif;line-height:1;font-weight:normal;font-style:normal;word-break:break-all" target="_blank"><div class="pickLayout2_inner" style="display:flex"><div class="pickLayout2_info" style="flex:1 1 0%;overflow:hidden;min-width:56px"><div class="pickLayout2_title pickLayout2_title--medium" style="font-weight:bold;margin-bottom:8px;overflow:hidden;color:#333;text-align:left;white-space:normal;text-overflow:ellipsis;font-size:14px;line-height:1.3;max-height:3em;-webkit-box-orient:vertical;display:-webkit-box;-webkit-line-clamp:2;margin-top:19px">問題解決のための「アルゴリズム×数学」が基礎からしっかり身につく本</div><div class="pickLayout2_advertiser pickLayout2_advertiser--medium" style="font-size:10px;color:#757575;text-align:left;overflow:hidden;white-space:nowrap;text-overflow:ellipsis">Amazon（アマゾン）</div><div class="pickLayout2_price pickLayout2_price--medium" style="color:#333;text-align:left;font-size:14px;margin-top:12px;margin-bottom:12px">&nbsp;</div></div><div class="pickLayout2_imgWrapper pickLayout2_imgWrapper--medium" style="padding:4px 0;position:relative;margin-left:16px;width:144px;height:144px;flex-shrink:0"><img alt="" class="pickLayout2_img" data-img="affiliate" height="144" src="https://m.media-amazon.com/images/I/51Q+KKW3EyL._SL500_.jpg" style="width:auto;height:auto;margin:auto; margin: auto;position:absolute;top:0;left:0;right:0;bottom:0;max-width:100%;max-height:100%" width="144"></div></div></a><ul class="addShopLink_list" style="max-width:450px;padding:0;font-weight:bold;font-size:14px;font-family:Hiragino Kaku Gothic Pro;margin:0;list-style:none"><li class="addShopLink_listItem" style="display:block;width:100%;margin-top:8px"><a class="pickLink addShopLink_listItemLink" data-aid="ykOR0IcilbDgDclawa49k4" data-df-item-id="4297125218" data-item-id="AZ000001" data-layout-type="101" href="https://d.odsyms15.com/click?aid=ykOR0IcilbDgDclawa49k4" id="ykOR0IcilbDgDclawa49k4" rel="noopener" style="display:flex;align-items:center;box-sizing:border-box;height:36px;padding:12px;padding-right:16px;color:#333;font-weight:bold;font-size:12px;text-decoration:none;background-color:#f8f8f8" target="_blank"><span class="addShopLink_listItemLinkShopName" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap">Amazon（アマゾン）</span><span class="addShopLink_listItemLinkShopMore" style="flex:1;word-break:keep-all;text-align:left">で詳細を見る</span><div class="addShopLink_listItemLinkArrow" style="display:inline-block;margin-left:auto;padding:5px;border-color:#757575;border-style:solid;border-top-width:0;border-right-width:2px;border-bottom-width:2px;border-left-width:0;transform:rotate(-45deg)"><div class="addShopLink_nothing" style="display:none">&nbsp;</div></div></a></li><li class="addShopLink_listItem" style="display:block;width:100%;margin-top:8px"><a class="pickLink addShopLink_listItemLink" data-aid="oPq5JN5vM0CpUTkHG1Uz24" data-df-item-id="azusa:10000143" data-item-id="RK000001" data-layout-type="101" href="https://d.odsyms15.com/click?aid=oPq5JN5vM0CpUTkHG1Uz24" id="oPq5JN5vM0CpUTkHG1Uz24" rel="noopener" style="display:flex;align-items:center;box-sizing:border-box;height:36px;padding:12px;padding-right:16px;color:#333;font-weight:bold;font-size:12px;text-decoration:none;background-color:#f8f8f8" target="_blank"><span class="addShopLink_listItemLinkShopName" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap">楽天市場</span><span class="addShopLink_listItemLinkShopMore" style="flex:1;word-break:keep-all;text-align:left">で詳細を見る</span><div data-eventlabel-end="1735570740" data-eventlabel-itemid="RK000001" data-eventlabel-start="1735484400" hidden style="background-color:#d91c0b;flex-shrink:0;font-size:10px;font-weight:bold;color:#fff;padding:4px 8px;border-radius:4px;margin:0 8px;box-sizing:border-box;width:-webkit-fit-content; width: -moz-fit-content; width: fit-content;line-height:1.2;max-width:5em;text-overflow:ellipsis;overflow:hidden;white-space:nowrap">${EVENT_LABEL_02_TEXT}</div><div class="addShopLink_listItemLinkArrow" style="display:inline-block;margin-left:auto;padding:5px;border-color:#757575;border-style:solid;border-top-width:0;border-right-width:2px;border-bottom-width:2px;border-left-width:0;transform:rotate(-45deg)"><div class="addShopLink_nothing" style="display:none">&nbsp;</div></div></a></li></ul></article></div><p>&nbsp;</p><div class="pickCreative_root" style="font-size:0"><article class="pickCreative_wrap" contenteditable="false" style="display:inline-block;max-width:100%"><a class="pickCreative pickLayout2" data-aid="88S2j2c7HlQw1SCn3zQcj6" data-detail-setting="{&quot;show_price&quot;:false}" data-df-item-id="B0BDZGDM9J" data-img-size="medium" data-img-url="https://m.media-amazon.com/images/I/51g2fFApKBL._SL500_.jpg" data-item-id="AZ000001" data-layout-type="2" href="https://d.odsyms15.com/click?aid=88S2j2c7HlQw1SCn3zQcj6" id="88S2j2c7HlQw1SCn3zQcj6" style="background-color:#fff;border-radius:4px;box-sizing:border-box;display:block;max-width:100%;padding:4px 8px;text-decoration:none;width:450px;font-family:ヒラギノ角ゴ Pro W3, Hiragino Kaku Gothic Pro, ＭＳ Ｐゴシック, Helvetica, Arial, sans-serif;line-height:1;font-weight:normal;font-style:normal;word-break:break-all" target="_blank"><div class="pickLayout2_inner" style="display:flex"><div class="pickLayout2_info" style="flex:1 1 0%;overflow:hidden;min-width:56px"><div class="pickLayout2_title pickLayout2_title--medium" style="font-weight:bold;margin-bottom:8px;overflow:hidden;color:#333;text-align:left;white-space:normal;text-overflow:ellipsis;font-size:14px;line-height:1.3;max-height:3em;-webkit-box-orient:vertical;display:-webkit-box;-webkit-line-clamp:2;margin-top:19px">競技プログラミングの鉄則 (Compass Booksシリーズ)</div><div class="pickLayout2_advertiser pickLayout2_advertiser--medium" style="font-size:10px;color:#757575;text-align:left;overflow:hidden;white-space:nowrap;text-overflow:ellipsis">Amazon（アマゾン）</div><div class="pickLayout2_price pickLayout2_price--medium" style="color:#333;text-align:left;font-size:14px;margin-top:12px;margin-bottom:12px">&nbsp;</div></div><div class="pickLayout2_imgWrapper pickLayout2_imgWrapper--medium" style="padding:4px 0;position:relative;margin-left:16px;width:144px;height:144px;flex-shrink:0"><img alt="" class="pickLayout2_img" data-img="affiliate" height="144" src="https://m.media-amazon.com/images/I/51g2fFApKBL._SL500_.jpg" style="width:auto;height:auto;margin:auto; margin: auto;position:absolute;top:0;left:0;right:0;bottom:0;max-width:100%;max-height:100%" width="144"></div></div></a></article></div><p>&nbsp;</p></div><p>&nbsp;</p><p>&nbsp;</p><p><br>&nbsp;</p>
]]>
</description>
<link>https://ameblo.jp/tonakai0521/entry-12914886587.html</link>
<pubDate>Sun, 06 Jul 2025 18:07:16 +0900</pubDate>
</item>
<item>
<title>【解説】413C AtCoder Beginner Contest</title>
<description>
<![CDATA[ <h2>AtCoder Beginner Contest 413&nbsp;C - Large Queue</h2><p>使用言語はPythonです。</p><h2 data-end="177" data-start="169">問題の概要</h2><p data-end="228" data-start="179">最初、空の整数列Aがあります。Q個のクエリが順番に与えられ、それぞれ以下のどちらかの操作をします。</p><ul data-end="333" data-start="230"><li data-end="271" data-start="230"><p data-end="271" data-start="232"><strong data-end="240" data-start="232">タイプ1</strong>：「1 c x」<br data-end="251" data-start="248">整数xをc個、末尾にまとめて追加します。</p></li><li data-end="333" data-start="273"><p data-end="333" data-start="275"><strong data-end="283" data-start="275">タイプ2</strong>：「2 k」<br data-end="292" data-start="289">先頭からk個の整数を削除し、その合計を出力します。kは必ず現在のAの長さ以下です。</p></li></ul><hr data-end="338" data-start="335"><h2 data-end="352" data-start="340">この問題のポイント</h2><p data-end="415" data-start="354">一見すると単純ですが、cやkが最大で10^9と非常に大きいため、単純に一つ一つの整数を扱うと処理時間がかかってしまいます。</p><p data-end="456" data-start="417">そのため、「同じ数が連続している場合はまとめて管理する」という工夫が必要です。</p><hr data-end="461" data-start="458"><h2 data-end="473" data-start="463">どう管理する？</h2><p data-end="531" data-start="475">例えば、「数xを1000000000個追加する」といったとき、これを全部1つずつリストに入れるのは無理ですよね。</p><p data-end="559" data-start="533">そこで、「(個数, 値)」の形でデータを管理します。</p><p data-end="603" data-start="561">末尾に追加するときは、deque（両端キュー）に「(c, x)」をまとめて入れます。</p><p data-end="661" data-start="605">削除するときは、先頭から順に「(c, x)」の単位で処理し、必要なら途中で分割して戻すことで高速に処理できます。</p><hr data-end="666" data-start="663"><h2 data-end="677" data-start="668">実際のコード</h2><p data-end="722" data-start="679">Q = int(input())<br data-end="698" data-start="695">A = deque()<br data-end="712" data-start="709">ANS = []</p><p data-end="1078" data-start="724">for _ in range(Q):<br data-end="745" data-start="742"> query = list(map(int, input().split()))<br data-end="788" data-start="785"> if query[0] == 1:<br data-end="809" data-start="806">  c, x = query[1], query[2]<br data-end="839" data-start="836">  A.append([c, x])<br data-end="860" data-start="857"> else:<br data-end="869" data-start="866">  k = query[1]<br data-end="886" data-start="883">  ans = 0<br data-end="898" data-start="895">  while k &gt; 0:<br data-end="915" data-start="912">   c, x = A.popleft()<br data-end="939" data-start="936">   if k &lt; c:<br data-end="954" data-start="951">    A.appendleft([c - k, x])<br data-end="985" data-start="982">    ans += k * x<br data-end="1004" data-start="1001">    k = 0<br data-end="1016" data-start="1013">   else:<br data-end="1027" data-start="1024">    ans += c * x<br data-end="1046" data-start="1043">    k -= c<br data-end="1059" data-start="1056">  ANS.append(ans)</p><p data-end="1107" data-start="1080">for a in ANS:<br data-end="1096" data-start="1093"> print(a)</p><hr data-end="1112" data-start="1109"><h2 data-end="1120" data-start="1114">最後に</h2><p data-end="1172" data-start="1122">このように「同じ値の連続をまとめて管理する」という考え方は、大量のデータを扱う問題で非常に重要です。</p><p data-end="1230" data-start="1174">また、dequeを使うことで先頭の要素を高速に取り出したり戻したりできるため、大量の削除処理も効率よく行えます。</p><p data-end="1252" data-start="1232">ぜひ自分でも実装して試してみてください！</p><main id="main"><p>&nbsp;</p></main><div class="ogpCard_root"><div class="pickCreative_root" style="font-size:0"><article class="pickCreative_wrap" contenteditable="false" style="display:inline-block;max-width:100%"><a class="pickCreative pickLayout2" data-aid="zFz0yENiG7uMabBUgKrGD2" data-detail-setting="{&quot;show_price&quot;:false}" data-df-item-id="4297125218" data-img-size="medium" data-img-url="https://m.media-amazon.com/images/I/51Q+KKW3EyL._SL500_.jpg" data-item-id="AZ000001" data-layout-type="2" href="https://d.odsyms15.com/click?aid=zFz0yENiG7uMabBUgKrGD2" id="zFz0yENiG7uMabBUgKrGD2" style="background-color:#fff;border-radius:4px;box-sizing:border-box;display:block;max-width:100%;padding:4px 8px;text-decoration:none;width:450px;font-family:ヒラギノ角ゴ Pro W3, Hiragino Kaku Gothic Pro, ＭＳ Ｐゴシック, Helvetica, Arial, sans-serif;line-height:1;font-weight:normal;font-style:normal;word-break:break-all" target="_blank"><div class="pickLayout2_inner" style="display:flex"><div class="pickLayout2_info" style="flex:1 1 0%;overflow:hidden;min-width:56px"><div class="pickLayout2_title pickLayout2_title--medium" style="font-weight:bold;margin-bottom:8px;overflow:hidden;color:#333;text-align:left;white-space:normal;text-overflow:ellipsis;font-size:14px;line-height:1.3;max-height:3em;-webkit-box-orient:vertical;display:-webkit-box;-webkit-line-clamp:2;margin-top:19px">問題解決のための「アルゴリズム×数学」が基礎からしっかり身につく本</div><div class="pickLayout2_advertiser pickLayout2_advertiser--medium" style="font-size:10px;color:#757575;text-align:left;overflow:hidden;white-space:nowrap;text-overflow:ellipsis">Amazon（アマゾン）</div><div class="pickLayout2_price pickLayout2_price--medium" style="color:#333;text-align:left;font-size:14px;margin-top:12px;margin-bottom:12px">&nbsp;</div></div><div class="pickLayout2_imgWrapper pickLayout2_imgWrapper--medium" style="padding:4px 0;position:relative;margin-left:16px;width:144px;height:144px;flex-shrink:0"><img alt="" class="pickLayout2_img" data-img="affiliate" height="144" src="https://m.media-amazon.com/images/I/51Q+KKW3EyL._SL500_.jpg" style="width:auto;height:auto;margin:auto; margin: auto;position:absolute;top:0;left:0;right:0;bottom:0;max-width:100%;max-height:100%" width="144"></div></div></a><ul class="addShopLink_list" style="max-width:450px;padding:0;font-weight:bold;font-size:14px;font-family:Hiragino Kaku Gothic Pro;margin:0;list-style:none"><li class="addShopLink_listItem" style="display:block;width:100%;margin-top:8px"><a class="pickLink addShopLink_listItemLink" data-aid="5FOijcGE3yU1c1hx3j0Mv5" data-df-item-id="4297125218" data-item-id="AZ000001" data-layout-type="101" href="https://d.odsyms15.com/click?aid=5FOijcGE3yU1c1hx3j0Mv5" id="5FOijcGE3yU1c1hx3j0Mv5" rel="noopener" style="display:flex;align-items:center;box-sizing:border-box;height:36px;padding:12px;padding-right:16px;color:#333;font-weight:bold;font-size:12px;text-decoration:none;background-color:#f8f8f8" target="_blank"><span class="addShopLink_listItemLinkShopName" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap">Amazon（アマゾン）</span><span class="addShopLink_listItemLinkShopMore" style="flex:1;word-break:keep-all;text-align:left">で詳細を見る</span><div class="addShopLink_listItemLinkArrow" style="display:inline-block;margin-left:auto;padding:5px;border-color:#757575;border-style:solid;border-top-width:0;border-right-width:2px;border-bottom-width:2px;border-left-width:0;transform:rotate(-45deg)"><div class="addShopLink_nothing" style="display:none">&nbsp;</div></div></a></li><li class="addShopLink_listItem" style="display:block;width:100%;margin-top:8px"><a class="pickLink addShopLink_listItemLink" data-aid="jtz0Hg8Mw3ZrpztHYKwmJ3" data-df-item-id="azusa:10000143" data-item-id="RK000001" data-layout-type="101" href="https://d.odsyms15.com/click?aid=jtz0Hg8Mw3ZrpztHYKwmJ3" id="jtz0Hg8Mw3ZrpztHYKwmJ3" rel="noopener" style="display:flex;align-items:center;box-sizing:border-box;height:36px;padding:12px;padding-right:16px;color:#333;font-weight:bold;font-size:12px;text-decoration:none;background-color:#f8f8f8" target="_blank"><span class="addShopLink_listItemLinkShopName" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap">楽天市場</span><span class="addShopLink_listItemLinkShopMore" style="flex:1;word-break:keep-all;text-align:left">で詳細を見る</span><div data-eventlabel-end="1735570740" data-eventlabel-itemid="RK000001" data-eventlabel-start="1735484400" hidden style="background-color:#d91c0b;flex-shrink:0;font-size:10px;font-weight:bold;color:#fff;padding:4px 8px;border-radius:4px;margin:0 8px;box-sizing:border-box;width:-webkit-fit-content; width: -moz-fit-content; width: fit-content;line-height:1.2;max-width:5em;text-overflow:ellipsis;overflow:hidden;white-space:nowrap">${EVENT_LABEL_02_TEXT}</div><div class="addShopLink_listItemLinkArrow" style="display:inline-block;margin-left:auto;padding:5px;border-color:#757575;border-style:solid;border-top-width:0;border-right-width:2px;border-bottom-width:2px;border-left-width:0;transform:rotate(-45deg)"><div class="addShopLink_nothing" style="display:none">&nbsp;</div></div></a></li></ul></article></div><p>&nbsp;</p><div class="pickCreative_root" style="font-size:0"><article class="pickCreative_wrap" contenteditable="false" style="display:inline-block;max-width:100%"><a class="pickCreative pickLayout2" data-aid="SHiTkE6AkWG0dFR1TUmcHn" data-detail-setting="{&quot;show_price&quot;:false}" data-df-item-id="B0BDZGDM9J" data-img-size="medium" data-img-url="https://m.media-amazon.com/images/I/51g2fFApKBL._SL500_.jpg" data-item-id="AZ000001" data-layout-type="2" href="https://d.odsyms15.com/click?aid=SHiTkE6AkWG0dFR1TUmcHn" id="SHiTkE6AkWG0dFR1TUmcHn" style="background-color:#fff;border-radius:4px;box-sizing:border-box;display:block;max-width:100%;padding:4px 8px;text-decoration:none;width:450px;font-family:ヒラギノ角ゴ Pro W3, Hiragino Kaku Gothic Pro, ＭＳ Ｐゴシック, Helvetica, Arial, sans-serif;line-height:1;font-weight:normal;font-style:normal;word-break:break-all" target="_blank"><div class="pickLayout2_inner" style="display:flex"><div class="pickLayout2_info" style="flex:1 1 0%;overflow:hidden;min-width:56px"><div class="pickLayout2_title pickLayout2_title--medium" style="font-weight:bold;margin-bottom:8px;overflow:hidden;color:#333;text-align:left;white-space:normal;text-overflow:ellipsis;font-size:14px;line-height:1.3;max-height:3em;-webkit-box-orient:vertical;display:-webkit-box;-webkit-line-clamp:2;margin-top:19px">競技プログラミングの鉄則 (Compass Booksシリーズ)</div><div class="pickLayout2_advertiser pickLayout2_advertiser--medium" style="font-size:10px;color:#757575;text-align:left;overflow:hidden;white-space:nowrap;text-overflow:ellipsis">Amazon（アマゾン）</div><div class="pickLayout2_price pickLayout2_price--medium" style="color:#333;text-align:left;font-size:14px;margin-top:12px;margin-bottom:12px">&nbsp;</div></div><div class="pickLayout2_imgWrapper pickLayout2_imgWrapper--medium" style="padding:4px 0;position:relative;margin-left:16px;width:144px;height:144px;flex-shrink:0"><img alt="" class="pickLayout2_img" data-img="affiliate" height="144" src="https://m.media-amazon.com/images/I/51g2fFApKBL._SL500_.jpg" style="width:auto;height:auto;margin:auto; margin: auto;position:absolute;top:0;left:0;right:0;bottom:0;max-width:100%;max-height:100%" width="144"></div></div></a></article></div><p>&nbsp;</p></div><p>&nbsp;</p><p>&nbsp;</p><p><br>&nbsp;</p>
]]>
</description>
<link>https://ameblo.jp/tonakai0521/entry-12914886172.html</link>
<pubDate>Sun, 06 Jul 2025 18:04:17 +0900</pubDate>
</item>
<item>
<title>【解説】413B AtCoder Beginner Contest</title>
<description>
<![CDATA[ <h2>AtCoder Beginner Contest 413&nbsp;B - cat 2</h2><p>使用言語はPythonです。</p><h2 data-end="209" data-start="201">問題の概要</h2><ul data-end="375" data-start="211"><li data-end="245" data-start="211"><p data-end="245" data-start="213">N種類の文字列 S1, S2, …, SN が与えられます。</p></li><li data-end="304" data-start="246"><p data-end="304" data-start="248">操作は1回だけ、異なる2つの文字列 Si と Sj（i ≠ j）を選んで、Si + Sj の順で連結します。</p></li><li data-end="332" data-start="305"><p data-end="332" data-start="307">連結してできる文字列の種類数を求めてください。</p></li><li data-end="375" data-start="333"><p data-end="375" data-start="335">異なるペア (i, j) でも連結結果が同じ文字列なら、それは1通りと数えます。</p></li></ul><hr data-end="380" data-start="377"><h2 data-end="389" data-start="382">ポイント</h2><ul data-end="437" data-start="391"><li data-end="411" data-start="391"><p data-end="411" data-start="393">連結結果の重複は1回だけ数える。</p></li><li data-end="437" data-start="412"><p data-end="437" data-start="414">同じ文字列同士の連結（i = j）はできない。</p></li></ul><hr data-end="442" data-start="439"><h2 data-end="455" data-start="444">解き方のイメージ</h2><ol data-end="542" data-start="457"><li data-end="493" data-start="457"><p data-end="493" data-start="460">文字列リストの全ての異なる組み合わせ (i, j) を考える。</p></li><li data-end="523" data-start="494"><p data-end="523" data-start="497">連結した文字列をセットに追加し、重複を排除する。</p></li><li data-end="542" data-start="524"><p data-end="542" data-start="527">最終的にセットの大きさが答え。</p></li></ol><hr data-end="547" data-start="544"><h2 data-end="561" data-start="549">Pythonコード</h2><p data-end="752" data-start="563">N = int(input())<br data-end="582" data-start="579">L = set()<br data-end="594" data-start="591">S = []<br data-end="603" data-start="600">for i in range(N):<br data-end="624" data-start="621"> s = input()<br data-end="639" data-start="636"> S.append(s)<br data-end="654" data-start="651">for i in range(0, N-1):<br data-end="680" data-start="677"> for j in range(i+1, N):<br data-end="707" data-start="704">  L.add(S[i] + S[j])<br data-end="730" data-start="727">  L.add(S[j] + S[i])</p><p data-end="767" data-start="754">print(len(L))</p><hr data-end="772" data-start="769"><h2 data-end="783" data-start="774">コードの説明</h2><ul data-end="948" data-start="785"><li data-end="808" data-start="785"><p data-end="808" data-start="787">入力したN個の文字列をリストSに格納。</p></li><li data-end="839" data-start="809"><p data-end="839" data-start="811">集合Lに異なる2つの文字列の連結結果を追加していく。</p></li><li data-end="897" data-start="840"><p data-end="897" data-start="842">i &lt; j の範囲でループし、S[i] + S[j] と S[j] + S[i] の両方をセットに入れる。</p></li><li data-end="931" data-start="898"><p data-end="931" data-start="900">セットは重複を除くため、同じ連結結果は1回だけ数えられる。</p></li><li data-end="948" data-start="932"><p data-end="948" data-start="934">最後にセットの大きさを出力。</p></li></ul><hr data-end="953" data-start="950"><h2 data-end="961" data-start="955">&nbsp;</h2><h2 data-end="1061" data-start="1055">まとめ</h2><ul data-end="1147" data-start="1063"><li data-end="1087" data-start="1063"><p data-end="1087" data-start="1065">異なる2つの文字列の連結結果の種類数は、</p></li><li data-end="1123" data-start="1088"><p data-end="1123" data-start="1090">全組み合わせの連結をセットに追加して重複を除けば簡単に求まる。</p></li><li data-end="1147" data-start="1124"><p data-end="1147" data-start="1126">Pythonのセットは重複排除に便利。</p></li></ul><main id="main"><p>&nbsp;</p></main><div class="ogpCard_root"><div class="pickCreative_root" style="font-size:0"><article class="pickCreative_wrap" contenteditable="false" style="display:inline-block;max-width:100%"><a class="pickCreative pickLayout2" data-aid="bTWAv1AMmnV7V1Ko2SZdU2" data-detail-setting="{&quot;show_price&quot;:false}" data-df-item-id="4297125218" data-img-size="medium" data-img-url="https://m.media-amazon.com/images/I/51Q+KKW3EyL._SL500_.jpg" data-item-id="AZ000001" data-layout-type="2" href="https://d.odsyms15.com/click?aid=bTWAv1AMmnV7V1Ko2SZdU2" id="bTWAv1AMmnV7V1Ko2SZdU2" style="background-color:#fff;border-radius:4px;box-sizing:border-box;display:block;max-width:100%;padding:4px 8px;text-decoration:none;width:450px;font-family:ヒラギノ角ゴ Pro W3, Hiragino Kaku Gothic Pro, ＭＳ Ｐゴシック, Helvetica, Arial, sans-serif;line-height:1;font-weight:normal;font-style:normal;word-break:break-all" target="_blank"><div class="pickLayout2_inner" style="display:flex"><div class="pickLayout2_info" style="flex:1 1 0%;overflow:hidden;min-width:56px"><div class="pickLayout2_title pickLayout2_title--medium" style="font-weight:bold;margin-bottom:8px;overflow:hidden;color:#333;text-align:left;white-space:normal;text-overflow:ellipsis;font-size:14px;line-height:1.3;max-height:3em;-webkit-box-orient:vertical;display:-webkit-box;-webkit-line-clamp:2;margin-top:19px">問題解決のための「アルゴリズム×数学」が基礎からしっかり身につく本</div><div class="pickLayout2_advertiser pickLayout2_advertiser--medium" style="font-size:10px;color:#757575;text-align:left;overflow:hidden;white-space:nowrap;text-overflow:ellipsis">Amazon（アマゾン）</div><div class="pickLayout2_price pickLayout2_price--medium" style="color:#333;text-align:left;font-size:14px;margin-top:12px;margin-bottom:12px">&nbsp;</div></div><div class="pickLayout2_imgWrapper pickLayout2_imgWrapper--medium" style="padding:4px 0;position:relative;margin-left:16px;width:144px;height:144px;flex-shrink:0"><img alt="" class="pickLayout2_img" data-img="affiliate" height="144" src="https://m.media-amazon.com/images/I/51Q+KKW3EyL._SL500_.jpg" style="width:auto;height:auto;margin:auto; margin: auto;position:absolute;top:0;left:0;right:0;bottom:0;max-width:100%;max-height:100%" width="144"></div></div></a><ul class="addShopLink_list" style="max-width:450px;padding:0;font-weight:bold;font-size:14px;font-family:Hiragino Kaku Gothic Pro;margin:0;list-style:none"><li class="addShopLink_listItem" style="display:block;width:100%;margin-top:8px"><a class="pickLink addShopLink_listItemLink" data-aid="90PsKHB5k0s4CCRlHgI544" data-df-item-id="4297125218" data-item-id="AZ000001" data-layout-type="101" href="https://d.odsyms15.com/click?aid=90PsKHB5k0s4CCRlHgI544" id="90PsKHB5k0s4CCRlHgI544" rel="noopener" style="display:flex;align-items:center;box-sizing:border-box;height:36px;padding:12px;padding-right:16px;color:#333;font-weight:bold;font-size:12px;text-decoration:none;background-color:#f8f8f8" target="_blank"><span class="addShopLink_listItemLinkShopName" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap">Amazon（アマゾン）</span><span class="addShopLink_listItemLinkShopMore" style="flex:1;word-break:keep-all;text-align:left">で詳細を見る</span><div class="addShopLink_listItemLinkArrow" style="display:inline-block;margin-left:auto;padding:5px;border-color:#757575;border-style:solid;border-top-width:0;border-right-width:2px;border-bottom-width:2px;border-left-width:0;transform:rotate(-45deg)"><div class="addShopLink_nothing" style="display:none">&nbsp;</div></div></a></li><li class="addShopLink_listItem" style="display:block;width:100%;margin-top:8px"><a class="pickLink addShopLink_listItemLink" data-aid="5ib5oWpLKriQPmG8x5dGiP" data-df-item-id="azusa:10000143" data-item-id="RK000001" data-layout-type="101" href="https://d.odsyms15.com/click?aid=5ib5oWpLKriQPmG8x5dGiP" id="5ib5oWpLKriQPmG8x5dGiP" rel="noopener" style="display:flex;align-items:center;box-sizing:border-box;height:36px;padding:12px;padding-right:16px;color:#333;font-weight:bold;font-size:12px;text-decoration:none;background-color:#f8f8f8" target="_blank"><span class="addShopLink_listItemLinkShopName" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap">楽天市場</span><span class="addShopLink_listItemLinkShopMore" style="flex:1;word-break:keep-all;text-align:left">で詳細を見る</span><div data-eventlabel-end="1735570740" data-eventlabel-itemid="RK000001" data-eventlabel-start="1735484400" hidden style="background-color:#d91c0b;flex-shrink:0;font-size:10px;font-weight:bold;color:#fff;padding:4px 8px;border-radius:4px;margin:0 8px;box-sizing:border-box;width:-webkit-fit-content; width: -moz-fit-content; width: fit-content;line-height:1.2;max-width:5em;text-overflow:ellipsis;overflow:hidden;white-space:nowrap">${EVENT_LABEL_02_TEXT}</div><div class="addShopLink_listItemLinkArrow" style="display:inline-block;margin-left:auto;padding:5px;border-color:#757575;border-style:solid;border-top-width:0;border-right-width:2px;border-bottom-width:2px;border-left-width:0;transform:rotate(-45deg)"><div class="addShopLink_nothing" style="display:none">&nbsp;</div></div></a></li></ul></article></div><p>&nbsp;</p><div class="pickCreative_root" style="font-size:0"><article class="pickCreative_wrap" contenteditable="false" style="display:inline-block;max-width:100%"><a class="pickCreative pickLayout2" data-aid="bchhKFwqjJvUQHZU0VZeta" data-detail-setting="{&quot;show_price&quot;:false}" data-df-item-id="B0BDZGDM9J" data-img-size="medium" data-img-url="https://m.media-amazon.com/images/I/51g2fFApKBL._SL500_.jpg" data-item-id="AZ000001" data-layout-type="2" href="https://d.odsyms15.com/click?aid=bchhKFwqjJvUQHZU0VZeta" id="bchhKFwqjJvUQHZU0VZeta" style="background-color:#fff;border-radius:4px;box-sizing:border-box;display:block;max-width:100%;padding:4px 8px;text-decoration:none;width:450px;font-family:ヒラギノ角ゴ Pro W3, Hiragino Kaku Gothic Pro, ＭＳ Ｐゴシック, Helvetica, Arial, sans-serif;line-height:1;font-weight:normal;font-style:normal;word-break:break-all" target="_blank"><div class="pickLayout2_inner" style="display:flex"><div class="pickLayout2_info" style="flex:1 1 0%;overflow:hidden;min-width:56px"><div class="pickLayout2_title pickLayout2_title--medium" style="font-weight:bold;margin-bottom:8px;overflow:hidden;color:#333;text-align:left;white-space:normal;text-overflow:ellipsis;font-size:14px;line-height:1.3;max-height:3em;-webkit-box-orient:vertical;display:-webkit-box;-webkit-line-clamp:2;margin-top:19px">競技プログラミングの鉄則 (Compass Booksシリーズ)</div><div class="pickLayout2_advertiser pickLayout2_advertiser--medium" style="font-size:10px;color:#757575;text-align:left;overflow:hidden;white-space:nowrap;text-overflow:ellipsis">Amazon（アマゾン）</div><div class="pickLayout2_price pickLayout2_price--medium" style="color:#333;text-align:left;font-size:14px;margin-top:12px;margin-bottom:12px">&nbsp;</div></div><div class="pickLayout2_imgWrapper pickLayout2_imgWrapper--medium" style="padding:4px 0;position:relative;margin-left:16px;width:144px;height:144px;flex-shrink:0"><img alt="" class="pickLayout2_img" data-img="affiliate" height="144" src="https://m.media-amazon.com/images/I/51g2fFApKBL._SL500_.jpg" style="width:auto;height:auto;margin:auto; margin: auto;position:absolute;top:0;left:0;right:0;bottom:0;max-width:100%;max-height:100%" width="144"></div></div></a></article></div><p>&nbsp;</p></div><p>&nbsp;</p><p>&nbsp;</p><p><br>&nbsp;</p>
]]>
</description>
<link>https://ameblo.jp/tonakai0521/entry-12914884568.html</link>
<pubDate>Sun, 06 Jul 2025 17:59:56 +0900</pubDate>
</item>
<item>
<title>【解説】413 A AtCoder Beginner Contest</title>
<description>
<![CDATA[ <h2>AtCoder Beginner Contest 413&nbsp;A - Content Too Large</h2><p data-end="227" data-start="159">問題文<br data-end="165" data-start="162">高橋くんは、N個の品物と1つのカバンを持っています。<br data-end="194" data-start="191">i番目の品物の大きさは Ai で、カバンの大きさは M です。</p><p data-end="284" data-start="229">カバンに入れようとしている品物の大きさの合計が M 以下のとき、すべて同時にカバンに入れることができます。</p><p data-end="340" data-start="286">N個すべての品物を同時にカバンに入れることができるなら「Yes」、そうでなければ「No」と出力してください。</p><hr data-end="345" data-start="342"><p data-end="351" data-start="347">解説</p><p data-end="423" data-start="353">　最初に N と M を受け取ります。複数の数字を1行で入力するときは、map(int, input().split()) を使います。</p><p data-end="498" data-start="425">　次に、N個の品物の大きさをリストとして受け取りましょう。これは list(map(int, input().split())) で書けます。</p><p data-end="531" data-start="500">　リストAの合計は sum(A) で求めることができます。</p><p data-end="571" data-start="533">　この合計が M 以下なら「Yes」、それ以外なら「No」を出力します。</p><p data-end="633" data-start="573">　print("Yes" if 条件 else "No") という書き方を使うと、1行で分岐が書けてスッキリします。</p><hr data-end="638" data-start="635"><p data-end="654" data-start="640">下が実際のコードになります。</p><hr data-end="659" data-start="656"><h1 data-end="670" data-start="661">ACしたコード</h1><p data-end="744" data-start="672">N, M = map(int, input().split())<br data-end="707" data-start="704">A = list(map(int, input().split()))</p><p data-end="785" data-start="746">print("Yes" if sum(A) &lt;= M else "No")</p><hr data-end="790" data-start="787"><p data-end="796" data-start="792">補足</p><p data-end="865" data-start="798">・sum(A) でリストの合計が簡単に求められます。<br data-end="827" data-start="824">・三項演算子を使えば、if文を書かずに1行で条件に応じた出力ができます。</p><hr data-end="870" data-start="867"><p data-end="904" data-start="872">以上、N個の品物がカバンに入るかを判定する問題の解説でした！</p><main id="main"><p>&nbsp;</p></main><div class="ogpCard_root">&nbsp;</div><p>&nbsp;</p><div class="ogpCard_root">&nbsp;</div><p>&nbsp;</p><div class="ogpCard_root"><div class="pickCreative_root" style="font-size:0"><article class="pickCreative_wrap" contenteditable="false" style="display:inline-block;max-width:100%"><a class="pickCreative pickLayout2" data-aid="t03tG7cpLTXb0YSLLCziD7" data-detail-setting="{&quot;show_price&quot;:false}" data-df-item-id="4297125218" data-img-size="medium" data-img-url="https://m.media-amazon.com/images/I/51Q+KKW3EyL._SL500_.jpg" data-item-id="AZ000001" data-layout-type="2" href="https://d.odsyms15.com/click?aid=t03tG7cpLTXb0YSLLCziD7" id="t03tG7cpLTXb0YSLLCziD7" style="background-color:#fff;border-radius:4px;box-sizing:border-box;display:block;max-width:100%;padding:4px 8px;text-decoration:none;width:450px;font-family:ヒラギノ角ゴ Pro W3, Hiragino Kaku Gothic Pro, ＭＳ Ｐゴシック, Helvetica, Arial, sans-serif;line-height:1;font-weight:normal;font-style:normal;word-break:break-all" target="_blank"><div class="pickLayout2_inner" style="display:flex"><div class="pickLayout2_info" style="flex:1 1 0%;overflow:hidden;min-width:56px"><div class="pickLayout2_title pickLayout2_title--medium" style="font-weight:bold;margin-bottom:8px;overflow:hidden;color:#333;text-align:left;white-space:normal;text-overflow:ellipsis;font-size:14px;line-height:1.3;max-height:3em;-webkit-box-orient:vertical;display:-webkit-box;-webkit-line-clamp:2;margin-top:19px">問題解決のための「アルゴリズム×数学」が基礎からしっかり身につく本</div><div class="pickLayout2_advertiser pickLayout2_advertiser--medium" style="font-size:10px;color:#757575;text-align:left;overflow:hidden;white-space:nowrap;text-overflow:ellipsis">Amazon（アマゾン）</div><div class="pickLayout2_price pickLayout2_price--medium" style="color:#333;text-align:left;font-size:14px;margin-top:12px;margin-bottom:12px">&nbsp;</div></div><div class="pickLayout2_imgWrapper pickLayout2_imgWrapper--medium" style="padding:4px 0;position:relative;margin-left:16px;width:144px;height:144px;flex-shrink:0"><img alt="" class="pickLayout2_img" data-img="affiliate" height="144" src="https://m.media-amazon.com/images/I/51Q+KKW3EyL._SL500_.jpg" style="width:auto;height:auto;margin:auto; margin: auto;position:absolute;top:0;left:0;right:0;bottom:0;max-width:100%;max-height:100%" width="144"></div></div></a><ul class="addShopLink_list" style="max-width:450px;padding:0;font-weight:bold;font-size:14px;font-family:Hiragino Kaku Gothic Pro;margin:0;list-style:none"><li class="addShopLink_listItem" style="display:block;width:100%;margin-top:8px"><a class="pickLink addShopLink_listItemLink" data-aid="pndHLN3tfvW0zfJGPUBOZ3" data-df-item-id="4297125218" data-item-id="AZ000001" data-layout-type="101" href="https://d.odsyms15.com/click?aid=pndHLN3tfvW0zfJGPUBOZ3" id="pndHLN3tfvW0zfJGPUBOZ3" rel="noopener" style="display:flex;align-items:center;box-sizing:border-box;height:36px;padding:12px;padding-right:16px;color:#333;font-weight:bold;font-size:12px;text-decoration:none;background-color:#f8f8f8" target="_blank"><span class="addShopLink_listItemLinkShopName" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap">Amazon（アマゾン）</span><span class="addShopLink_listItemLinkShopMore" style="flex:1;word-break:keep-all;text-align:left">で詳細を見る</span><div class="addShopLink_listItemLinkArrow" style="display:inline-block;margin-left:auto;padding:5px;border-color:#757575;border-style:solid;border-top-width:0;border-right-width:2px;border-bottom-width:2px;border-left-width:0;transform:rotate(-45deg)"><div class="addShopLink_nothing" style="display:none">&nbsp;</div></div></a></li><li class="addShopLink_listItem" style="display:block;width:100%;margin-top:8px"><a class="pickLink addShopLink_listItemLink" data-aid="zjSz17L7d8BDcivRgtccZ4" data-df-item-id="azusa:10000143" data-item-id="RK000001" data-layout-type="101" href="https://d.odsyms15.com/click?aid=zjSz17L7d8BDcivRgtccZ4" id="zjSz17L7d8BDcivRgtccZ4" rel="noopener" style="display:flex;align-items:center;box-sizing:border-box;height:36px;padding:12px;padding-right:16px;color:#333;font-weight:bold;font-size:12px;text-decoration:none;background-color:#f8f8f8" target="_blank"><span class="addShopLink_listItemLinkShopName" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap">楽天市場</span><span class="addShopLink_listItemLinkShopMore" style="flex:1;word-break:keep-all;text-align:left">で詳細を見る</span><div data-eventlabel-end="1735570740" data-eventlabel-itemid="RK000001" data-eventlabel-start="1735484400" hidden style="background-color:#d91c0b;flex-shrink:0;font-size:10px;font-weight:bold;color:#fff;padding:4px 8px;border-radius:4px;margin:0 8px;box-sizing:border-box;width:-webkit-fit-content; width: -moz-fit-content; width: fit-content;line-height:1.2;max-width:5em;text-overflow:ellipsis;overflow:hidden;white-space:nowrap">${EVENT_LABEL_02_TEXT}</div><div class="addShopLink_listItemLinkArrow" style="display:inline-block;margin-left:auto;padding:5px;border-color:#757575;border-style:solid;border-top-width:0;border-right-width:2px;border-bottom-width:2px;border-left-width:0;transform:rotate(-45deg)"><div class="addShopLink_nothing" style="display:none">&nbsp;</div></div></a></li></ul></article></div><p>&nbsp;</p><div class="pickCreative_root" style="font-size:0"><article class="pickCreative_wrap" contenteditable="false" style="display:inline-block;max-width:100%"><a class="pickCreative pickLayout2" data-aid="eFTCRnZIYrf40NK2RIR5D5" data-detail-setting="{&quot;show_price&quot;:false}" data-df-item-id="B0BDZGDM9J" data-img-size="medium" data-img-url="https://m.media-amazon.com/images/I/51g2fFApKBL._SL500_.jpg" data-item-id="AZ000001" data-layout-type="2" href="https://d.odsyms15.com/click?aid=eFTCRnZIYrf40NK2RIR5D5" id="eFTCRnZIYrf40NK2RIR5D5" style="background-color:#fff;border-radius:4px;box-sizing:border-box;display:block;max-width:100%;padding:4px 8px;text-decoration:none;width:450px;font-family:ヒラギノ角ゴ Pro W3, Hiragino Kaku Gothic Pro, ＭＳ Ｐゴシック, Helvetica, Arial, sans-serif;line-height:1;font-weight:normal;font-style:normal;word-break:break-all" target="_blank"><div class="pickLayout2_inner" style="display:flex"><div class="pickLayout2_info" style="flex:1 1 0%;overflow:hidden;min-width:56px"><div class="pickLayout2_title pickLayout2_title--medium" style="font-weight:bold;margin-bottom:8px;overflow:hidden;color:#333;text-align:left;white-space:normal;text-overflow:ellipsis;font-size:14px;line-height:1.3;max-height:3em;-webkit-box-orient:vertical;display:-webkit-box;-webkit-line-clamp:2;margin-top:19px">競技プログラミングの鉄則 (Compass Booksシリーズ)</div><div class="pickLayout2_advertiser pickLayout2_advertiser--medium" style="font-size:10px;color:#757575;text-align:left;overflow:hidden;white-space:nowrap;text-overflow:ellipsis">Amazon（アマゾン）</div><div class="pickLayout2_price pickLayout2_price--medium" style="color:#333;text-align:left;font-size:14px;margin-top:12px;margin-bottom:12px">&nbsp;</div></div><div class="pickLayout2_imgWrapper pickLayout2_imgWrapper--medium" style="padding:4px 0;position:relative;margin-left:16px;width:144px;height:144px;flex-shrink:0"><img alt="" class="pickLayout2_img" data-img="affiliate" height="144" src="https://m.media-amazon.com/images/I/51g2fFApKBL._SL500_.jpg" style="width:auto;height:auto;margin:auto; margin: auto;position:absolute;top:0;left:0;right:0;bottom:0;max-width:100%;max-height:100%" width="144"></div></div></a></article></div><p>&nbsp;</p></div><p>&nbsp;</p><p>&nbsp;</p><p><br>&nbsp;</p>
]]>
</description>
<link>https://ameblo.jp/tonakai0521/entry-12905552644.html</link>
<pubDate>Sun, 06 Jul 2025 17:54:04 +0900</pubDate>
</item>
<item>
<title>【解説】401 C AtCoder Beginner Contest</title>
<description>
<![CDATA[ <h2>AtCoder Beginner Contest 401&nbsp;C - K-bonacci</h2><p>使用言語はPythonです。</p><p>&nbsp;</p><p><b style="font-weight:bold;">解説</b></p><p>　a まずは例外的な場合を考えると、N &lt; Kのときは全て１の配列になるのでAnも1となります。</p><p>&nbsp;</p><p>　それ以外の場合について考えます。</p><p>&nbsp;</p><p>　まず、A[0] ~ A[K-1] までは全て１なので、A[K] = K となります。</p><p>&nbsp;</p><p>　A[K+1] = <mark style="background-color:#ffdfbf;color:inherit;">A[1] + A[2] + ・・・ + A[K-1]</mark> + A[K] です</p><p>　ここで</p><p>　A[K] = A[0] + <mark style="background-color:#ffdfbf;color:inherit;">A[1] + A[2] + ・・・ + A[K-1]</mark><mark style="background-color:#ffffff;color:inherit;">　</mark>であることを利用すると、</p><p>&nbsp;</p><p>　A[K+1] = (A[K] - A[0]) + A[K]　となります</p><p>&nbsp;</p><p>　よってA[K+i+1] = A[K+i] - A[i] + A[K+i]　と表せることになります。</p><p>&nbsp;</p><p>　数字が大きくなるのでこのA[K+i]についてはその都度10**9のあまりを取ると良いです。</p><p>&nbsp;</p><p>　実装は下のようになります。</p><main id="main"><p>---------------ACしたコード--------------</p><p><mark style="background-color:#bfebff;color:inherit;">#入力</mark></p><p>N,K = map(int,input().split())</p><p>&nbsp;</p><p><mark style="background-color:#bfebff;color:inherit;">#例外処理</mark><br>if N &lt; K:<br>&nbsp; &nbsp; print(1)<br>&nbsp; &nbsp; exit(0)</p><p>&nbsp;</p><p><mark style="background-color:#bfebff;color:inherit;">#普通の場合</mark><br>else:<br>&nbsp; &nbsp; A = [1 for i in range(N+1)]<br>&nbsp; &nbsp; A[K] = K<br>&nbsp; &nbsp; for i in range(N-K):<br>&nbsp; &nbsp; &nbsp; &nbsp; A[i+K+1] = (A[K+i] + A[K+i] - A[i])%10**9<br>print(A[N])</p><p>-------------------------------------------</p><p>&nbsp;</p></main><div class="ogpCard_root"><div class="ogpCard_root"><p>提出したコードのリンク</p></div></div><p>↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓</p><p>&nbsp;</p><div class="ogpCard_root"><article class="ogpCard_wrap" contenteditable="false" style="display:inline-block;max-width:100%"><a class="ogpCard_link" data-ogp-card-log="" href="https://atcoder.jp/contests/abc401/submissions/64756580" rel="noopener noreferrer" style="display:flex;justify-content:space-between;overflow:hidden;box-sizing:border-box;width:620px;max-width:100%;height:120px;border:1px solid #e2e2e2;border-radius:4px;background-color:#fff;text-decoration:none" target="_blank"><span class="ogpCard_content" style="display:flex;flex-direction:column;overflow:hidden;width:100%;padding:16px"><span class="ogpCard_title" style="-webkit-box-orient:vertical;display:-webkit-box;-webkit-line-clamp:2;max-height:48px;line-height:1.4;font-size:16px;color:#333;text-align:left;font-weight:bold;overflow:hidden">Submission #64756580 - AtCoder Beginner Contest 401</span><span class="ogpCard_description" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:1.6;margin-top:4px;color:#757575;text-align:left;font-size:12px">AtCoder is a programming contest site for anyone from beginners to experts. We hold weekly programming contests online.</span><span class="ogpCard_url" style="display:flex;align-items:center;margin-top:auto"><span class="ogpCard_iconWrap" style="position:relative;width:20px;height:20px;flex-shrink:0"><img alt="リンク" class="ogpCard_icon" height="20" loading="lazy" src="https://c.stat100.ameba.jp/ameblo/symbols/v3.20.0/svg/gray/editor_link.svg" style="position:absolute;top:0;bottom:0;right:0;left:0;height:100%;max-height:100%" width="20"></span><span class="ogpCard_urlText" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#757575;font-size:12px;text-align:left">atcoder.jp</span></span></span><span class="ogpCard_imageWrap" style="position:relative;width:120px;height:120px;flex-shrink:0"><img alt="" class="ogpCard_image" data-ogp-card-image="" height="120" loading="lazy" src="https://img.atcoder.jp/assets/atcoder.png" style="position:absolute;top:50%;left:50%;object-fit:cover;min-height:100%;min-width:100%;transform:translate(-50%,-50%)" width="120"></span></a></article></div><p>&nbsp;</p><div class="ogpCard_root">&nbsp;</div><div class="ogpCard_root"><div class="pickCreative_root" style="font-size:0"><article class="pickCreative_wrap" contenteditable="false" style="display:inline-block;max-width:100%"><a class="pickCreative pickLayout2" data-aid="vR57YOOU2VlbvadaNyPhl4" data-detail-setting="{&quot;show_price&quot;:false}" data-df-item-id="4297125218" data-img-size="medium" data-img-url="https://m.media-amazon.com/images/I/51Q+KKW3EyL._SL500_.jpg" data-item-id="AZ000001" data-layout-type="2" href="https://d.odsyms15.com/click?aid=vR57YOOU2VlbvadaNyPhl4" id="vR57YOOU2VlbvadaNyPhl4" style="background-color:#fff;border-radius:4px;box-sizing:border-box;display:block;max-width:100%;padding:4px 8px;text-decoration:none;width:450px;font-family:ヒラギノ角ゴ Pro W3, Hiragino Kaku Gothic Pro, ＭＳ Ｐゴシック, Helvetica, Arial, sans-serif;line-height:1;font-weight:normal;font-style:normal;word-break:break-all" target="_blank"><div class="pickLayout2_inner" style="display:flex"><div class="pickLayout2_info" style="flex:1 1 0%;overflow:hidden;min-width:56px"><div class="pickLayout2_title pickLayout2_title--medium" style="font-weight:bold;margin-bottom:8px;overflow:hidden;color:#333;text-align:left;white-space:normal;text-overflow:ellipsis;font-size:14px;line-height:1.3;max-height:3em;-webkit-box-orient:vertical;display:-webkit-box;-webkit-line-clamp:2;margin-top:19px">問題解決のための「アルゴリズム×数学」が基礎からしっかり身につく本</div><div class="pickLayout2_advertiser pickLayout2_advertiser--medium" style="font-size:10px;color:#757575;text-align:left;overflow:hidden;white-space:nowrap;text-overflow:ellipsis">Amazon（アマゾン）</div><div class="pickLayout2_price pickLayout2_price--medium" style="color:#333;text-align:left;font-size:14px;margin-top:12px;margin-bottom:12px">&nbsp;</div></div><div class="pickLayout2_imgWrapper pickLayout2_imgWrapper--medium" style="padding:4px 0;position:relative;margin-left:16px;width:144px;height:144px;flex-shrink:0"><img alt="" class="pickLayout2_img" data-img="affiliate" height="144" src="https://m.media-amazon.com/images/I/51Q+KKW3EyL._SL500_.jpg" style="width:auto;height:auto;margin:auto; margin: auto;position:absolute;top:0;left:0;right:0;bottom:0;max-width:100%;max-height:100%" width="144"></div></div></a><ul class="addShopLink_list" style="max-width:450px;padding:0;font-weight:bold;font-size:14px;font-family:Hiragino Kaku Gothic Pro;margin:0;list-style:none"><li class="addShopLink_listItem" style="display:block;width:100%;margin-top:8px"><a class="pickLink addShopLink_listItemLink" data-aid="kmVNGMow35CV80o9xBTUF6" data-df-item-id="4297125218" data-item-id="AZ000001" data-layout-type="101" href="https://d.odsyms15.com/click?aid=kmVNGMow35CV80o9xBTUF6" id="kmVNGMow35CV80o9xBTUF6" rel="noopener" style="display:flex;align-items:center;box-sizing:border-box;height:36px;padding:12px;padding-right:16px;color:#333;font-weight:bold;font-size:12px;text-decoration:none;background-color:#f8f8f8" target="_blank"><span class="addShopLink_listItemLinkShopName" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap">Amazon（アマゾン）</span><span class="addShopLink_listItemLinkShopMore" style="flex:1;word-break:keep-all;text-align:left">で詳細を見る</span><div class="addShopLink_listItemLinkArrow" style="display:inline-block;margin-left:auto;padding:5px;border-color:#757575;border-style:solid;border-top-width:0;border-right-width:2px;border-bottom-width:2px;border-left-width:0;transform:rotate(-45deg)"><div class="addShopLink_nothing" style="display:none">&nbsp;</div></div></a></li><li class="addShopLink_listItem" style="display:block;width:100%;margin-top:8px"><a class="pickLink addShopLink_listItemLink" data-aid="wvFFSD6OKWYFYXvKmoShP2" data-df-item-id="azusa:10000143" data-item-id="RK000001" data-layout-type="101" href="https://d.odsyms15.com/click?aid=wvFFSD6OKWYFYXvKmoShP2" id="wvFFSD6OKWYFYXvKmoShP2" rel="noopener" style="display:flex;align-items:center;box-sizing:border-box;height:36px;padding:12px;padding-right:16px;color:#333;font-weight:bold;font-size:12px;text-decoration:none;background-color:#f8f8f8" target="_blank"><span class="addShopLink_listItemLinkShopName" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap">楽天市場</span><span class="addShopLink_listItemLinkShopMore" style="flex:1;word-break:keep-all;text-align:left">で詳細を見る</span><div data-eventlabel-end="1735570740" data-eventlabel-itemid="RK000001" data-eventlabel-start="1735484400" hidden style="background-color:#d91c0b;flex-shrink:0;font-size:10px;font-weight:bold;color:#fff;padding:4px 8px;border-radius:4px;margin:0 8px;box-sizing:border-box;width:-webkit-fit-content; width: -moz-fit-content; width: fit-content;line-height:1.2;max-width:5em;text-overflow:ellipsis;overflow:hidden;white-space:nowrap">${EVENT_LABEL_02_TEXT}</div><div class="addShopLink_listItemLinkArrow" style="display:inline-block;margin-left:auto;padding:5px;border-color:#757575;border-style:solid;border-top-width:0;border-right-width:2px;border-bottom-width:2px;border-left-width:0;transform:rotate(-45deg)"><div class="addShopLink_nothing" style="display:none">&nbsp;</div></div></a></li></ul></article></div><p>&nbsp;</p><div class="pickCreative_root" style="font-size:0"><article class="pickCreative_wrap" contenteditable="false" style="display:inline-block;max-width:100%"><a class="pickCreative pickLayout2" data-aid="TTGIGz8qwMmzvQsAb3Ye54" data-detail-setting="{&quot;show_price&quot;:false}" data-df-item-id="B0BDZGDM9J" data-img-size="medium" data-img-url="https://m.media-amazon.com/images/I/51g2fFApKBL._SL500_.jpg" data-item-id="AZ000001" data-layout-type="2" href="https://d.odsyms15.com/click?aid=TTGIGz8qwMmzvQsAb3Ye54" id="TTGIGz8qwMmzvQsAb3Ye54" style="background-color:#fff;border-radius:4px;box-sizing:border-box;display:block;max-width:100%;padding:4px 8px;text-decoration:none;width:450px;font-family:ヒラギノ角ゴ Pro W3, Hiragino Kaku Gothic Pro, ＭＳ Ｐゴシック, Helvetica, Arial, sans-serif;line-height:1;font-weight:normal;font-style:normal;word-break:break-all" target="_blank"><div class="pickLayout2_inner" style="display:flex"><div class="pickLayout2_info" style="flex:1 1 0%;overflow:hidden;min-width:56px"><div class="pickLayout2_title pickLayout2_title--medium" style="font-weight:bold;margin-bottom:8px;overflow:hidden;color:#333;text-align:left;white-space:normal;text-overflow:ellipsis;font-size:14px;line-height:1.3;max-height:3em;-webkit-box-orient:vertical;display:-webkit-box;-webkit-line-clamp:2;margin-top:19px">競技プログラミングの鉄則 (Compass Booksシリーズ)</div><div class="pickLayout2_advertiser pickLayout2_advertiser--medium" style="font-size:10px;color:#757575;text-align:left;overflow:hidden;white-space:nowrap;text-overflow:ellipsis">Amazon（アマゾン）</div><div class="pickLayout2_price pickLayout2_price--medium" style="color:#333;text-align:left;font-size:14px;margin-top:12px;margin-bottom:12px">&nbsp;</div></div><div class="pickLayout2_imgWrapper pickLayout2_imgWrapper--medium" style="padding:4px 0;position:relative;margin-left:16px;width:144px;height:144px;flex-shrink:0"><img alt="" class="pickLayout2_img" data-img="affiliate" height="144" src="https://m.media-amazon.com/images/I/51g2fFApKBL._SL500_.jpg" style="width:auto;height:auto;margin:auto; margin: auto;position:absolute;top:0;left:0;right:0;bottom:0;max-width:100%;max-height:100%" width="144"></div></div></a></article></div><p>&nbsp;</p></div><p>&nbsp;</p><p>&nbsp;</p><p><br>&nbsp;</p>
]]>
</description>
<link>https://ameblo.jp/tonakai0521/entry-12893827100.html</link>
<pubDate>Mon, 14 Apr 2025 13:05:30 +0900</pubDate>
</item>
<item>
<title>【解説】401 B AtCoder Beginner Contest</title>
<description>
<![CDATA[ <h2>AtCoder Beginner Contest 401&nbsp;B - Unauthorized</h2><p>使用言語はPythonです。</p><p>&nbsp;</p><p><b style="font-weight:bold;">解説</b></p><p><b style="font-weight:bold;">　</b></p><p>　cnt（カウント）で認証エラーの回数を記録します。</p><p>&nbsp;</p><p>　このcnt（カウント）が増えるのはログアウトした状態でprivate（非公開）にアクセスした時です</p><p>&nbsp;</p><p>　flagでログアウトしているかログインしているかの情報を保持することにします。</p><p>　flag = Trueならログインしている。</p><p>　flag = Falseならログアウトしている。</p><p>&nbsp;</p><p>　privateにアクセスしたときにflag = Falseであればcnt（カウント）を+1します</p><p>&nbsp;</p><p>　実際のコードは下のようになります。</p><p>　</p><main id="main"><p>---------------ACしたコード--------------</p><p><mark style="background-color:#bfebff;color:inherit;">#入力</mark></p><p>N = int(input())<br>cnt = 0<br>flag = False</p><p><br>for i in range(N):<br>&nbsp; &nbsp; S = input()<br>&nbsp; &nbsp; if S == "login":<br>&nbsp; &nbsp; &nbsp; &nbsp; flag = True<br>&nbsp; &nbsp; elif S == "logout":<br>&nbsp; &nbsp; &nbsp; &nbsp; flag = False<br>&nbsp; &nbsp; elif S == "private":<br>&nbsp; &nbsp; &nbsp; &nbsp; if flag == False:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cnt += 1</p><p><br>print(cnt)</p><p>-------------------------------------------</p><p>&nbsp;</p></main><div class="ogpCard_root"><div class="ogpCard_root"><p>提出したコードのリンク</p></div></div><p>↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓</p><p>&nbsp;</p><div class="ogpCard_root"><article class="ogpCard_wrap" contenteditable="false" style="display:inline-block;max-width:100%"><a class="ogpCard_link" data-ogp-card-log="" href="https://atcoder.jp/contests/abc401/submissions/64736428" rel="noopener noreferrer" style="display:flex;justify-content:space-between;overflow:hidden;box-sizing:border-box;width:620px;max-width:100%;height:120px;border:1px solid #e2e2e2;border-radius:4px;background-color:#fff;text-decoration:none" target="_blank"><span class="ogpCard_content" style="display:flex;flex-direction:column;overflow:hidden;width:100%;padding:16px"><span class="ogpCard_title" style="-webkit-box-orient:vertical;display:-webkit-box;-webkit-line-clamp:2;max-height:48px;line-height:1.4;font-size:16px;color:#333;text-align:left;font-weight:bold;overflow:hidden">Submission #64736428 - AtCoder Beginner Contest 401</span><span class="ogpCard_description" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:1.6;margin-top:4px;color:#757575;text-align:left;font-size:12px">AtCoder is a programming contest site for anyone from beginners to experts. We hold weekly programming contests online.</span><span class="ogpCard_url" style="display:flex;align-items:center;margin-top:auto"><span class="ogpCard_iconWrap" style="position:relative;width:20px;height:20px;flex-shrink:0"><img alt="リンク" class="ogpCard_icon" height="20" loading="lazy" src="https://c.stat100.ameba.jp/ameblo/symbols/v3.20.0/svg/gray/editor_link.svg" style="position:absolute;top:0;bottom:0;right:0;left:0;height:100%;max-height:100%" width="20"></span><span class="ogpCard_urlText" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#757575;font-size:12px;text-align:left">atcoder.jp</span></span></span><span class="ogpCard_imageWrap" style="position:relative;width:120px;height:120px;flex-shrink:0"><img alt="" class="ogpCard_image" data-ogp-card-image="" height="120" loading="lazy" src="https://img.atcoder.jp/assets/atcoder.png" style="position:absolute;top:50%;left:50%;object-fit:cover;min-height:100%;min-width:100%;transform:translate(-50%,-50%)" width="120"></span></a></article></div><p>&nbsp;</p><div class="ogpCard_root">&nbsp;</div><div class="ogpCard_root"><div class="pickCreative_root" style="font-size:0"><article class="pickCreative_wrap" contenteditable="false" style="display:inline-block;max-width:100%"><a class="pickCreative pickLayout2" data-aid="now8uu6JrGhliKonSET9f2" data-detail-setting="{&quot;show_price&quot;:false}" data-df-item-id="4297125218" data-img-size="medium" data-img-url="https://m.media-amazon.com/images/I/51Q+KKW3EyL._SL500_.jpg" data-item-id="AZ000001" data-layout-type="2" href="https://d.odsyms15.com/click?aid=now8uu6JrGhliKonSET9f2" id="now8uu6JrGhliKonSET9f2" style="background-color:#fff;border-radius:4px;box-sizing:border-box;display:block;max-width:100%;padding:4px 8px;text-decoration:none;width:450px;font-family:ヒラギノ角ゴ Pro W3, Hiragino Kaku Gothic Pro, ＭＳ Ｐゴシック, Helvetica, Arial, sans-serif;line-height:1;font-weight:normal;font-style:normal;word-break:break-all" target="_blank"><div class="pickLayout2_inner" style="display:flex"><div class="pickLayout2_info" style="flex:1 1 0%;overflow:hidden;min-width:56px"><div class="pickLayout2_title pickLayout2_title--medium" style="font-weight:bold;margin-bottom:8px;overflow:hidden;color:#333;text-align:left;white-space:normal;text-overflow:ellipsis;font-size:14px;line-height:1.3;max-height:3em;-webkit-box-orient:vertical;display:-webkit-box;-webkit-line-clamp:2;margin-top:19px">問題解決のための「アルゴリズム×数学」が基礎からしっかり身につく本</div><div class="pickLayout2_advertiser pickLayout2_advertiser--medium" style="font-size:10px;color:#757575;text-align:left;overflow:hidden;white-space:nowrap;text-overflow:ellipsis">Amazon（アマゾン）</div><div class="pickLayout2_price pickLayout2_price--medium" style="color:#333;text-align:left;font-size:14px;margin-top:12px;margin-bottom:12px">&nbsp;</div></div><div class="pickLayout2_imgWrapper pickLayout2_imgWrapper--medium" style="padding:4px 0;position:relative;margin-left:16px;width:144px;height:144px;flex-shrink:0"><img alt="" class="pickLayout2_img" data-img="affiliate" height="144" src="https://m.media-amazon.com/images/I/51Q+KKW3EyL._SL500_.jpg" style="width:auto;height:auto;margin:auto; margin: auto;position:absolute;top:0;left:0;right:0;bottom:0;max-width:100%;max-height:100%" width="144"></div></div></a><ul class="addShopLink_list" style="max-width:450px;padding:0;font-weight:bold;font-size:14px;font-family:Hiragino Kaku Gothic Pro;margin:0;list-style:none"><li class="addShopLink_listItem" style="display:block;width:100%;margin-top:8px"><a class="pickLink addShopLink_listItemLink" data-aid="loScrjDgQKPZjADFgR1hx4" data-df-item-id="4297125218" data-item-id="AZ000001" data-layout-type="101" href="https://d.odsyms15.com/click?aid=loScrjDgQKPZjADFgR1hx4" id="loScrjDgQKPZjADFgR1hx4" rel="noopener" style="display:flex;align-items:center;box-sizing:border-box;height:36px;padding:12px;padding-right:16px;color:#333;font-weight:bold;font-size:12px;text-decoration:none;background-color:#f8f8f8" target="_blank"><span class="addShopLink_listItemLinkShopName" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap">Amazon（アマゾン）</span><span class="addShopLink_listItemLinkShopMore" style="flex:1;word-break:keep-all;text-align:left">で詳細を見る</span><div class="addShopLink_listItemLinkArrow" style="display:inline-block;margin-left:auto;padding:5px;border-color:#757575;border-style:solid;border-top-width:0;border-right-width:2px;border-bottom-width:2px;border-left-width:0;transform:rotate(-45deg)"><div class="addShopLink_nothing" style="display:none">&nbsp;</div></div></a></li><li class="addShopLink_listItem" style="display:block;width:100%;margin-top:8px"><a class="pickLink addShopLink_listItemLink" data-aid="WoqZBUR5eD5eoOSHxltlR2" data-df-item-id="azusa:10000143" data-item-id="RK000001" data-layout-type="101" href="https://d.odsyms15.com/click?aid=WoqZBUR5eD5eoOSHxltlR2" id="WoqZBUR5eD5eoOSHxltlR2" rel="noopener" style="display:flex;align-items:center;box-sizing:border-box;height:36px;padding:12px;padding-right:16px;color:#333;font-weight:bold;font-size:12px;text-decoration:none;background-color:#f8f8f8" target="_blank"><span class="addShopLink_listItemLinkShopName" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap">楽天市場</span><span class="addShopLink_listItemLinkShopMore" style="flex:1;word-break:keep-all;text-align:left">で詳細を見る</span><div data-eventlabel-end="1735570740" data-eventlabel-itemid="RK000001" data-eventlabel-start="1735484400" hidden style="background-color:#d91c0b;flex-shrink:0;font-size:10px;font-weight:bold;color:#fff;padding:4px 8px;border-radius:4px;margin:0 8px;box-sizing:border-box;width:-webkit-fit-content; width: -moz-fit-content; width: fit-content;line-height:1.2;max-width:5em;text-overflow:ellipsis;overflow:hidden;white-space:nowrap">${EVENT_LABEL_02_TEXT}</div><div class="addShopLink_listItemLinkArrow" style="display:inline-block;margin-left:auto;padding:5px;border-color:#757575;border-style:solid;border-top-width:0;border-right-width:2px;border-bottom-width:2px;border-left-width:0;transform:rotate(-45deg)"><div class="addShopLink_nothing" style="display:none">&nbsp;</div></div></a></li></ul></article></div><p>&nbsp;</p><div class="pickCreative_root" style="font-size:0"><article class="pickCreative_wrap" contenteditable="false" style="display:inline-block;max-width:100%"><a class="pickCreative pickLayout2" data-aid="01JZ2WXXVHgzDzOnsn15bW" data-detail-setting="{&quot;show_price&quot;:false}" data-df-item-id="B0BDZGDM9J" data-img-size="medium" data-img-url="https://m.media-amazon.com/images/I/51g2fFApKBL._SL500_.jpg" data-item-id="AZ000001" data-layout-type="2" href="https://d.odsyms15.com/click?aid=01JZ2WXXVHgzDzOnsn15bW" id="01JZ2WXXVHgzDzOnsn15bW" style="background-color:#fff;border-radius:4px;box-sizing:border-box;display:block;max-width:100%;padding:4px 8px;text-decoration:none;width:450px;font-family:ヒラギノ角ゴ Pro W3, Hiragino Kaku Gothic Pro, ＭＳ Ｐゴシック, Helvetica, Arial, sans-serif;line-height:1;font-weight:normal;font-style:normal;word-break:break-all" target="_blank"><div class="pickLayout2_inner" style="display:flex"><div class="pickLayout2_info" style="flex:1 1 0%;overflow:hidden;min-width:56px"><div class="pickLayout2_title pickLayout2_title--medium" style="font-weight:bold;margin-bottom:8px;overflow:hidden;color:#333;text-align:left;white-space:normal;text-overflow:ellipsis;font-size:14px;line-height:1.3;max-height:3em;-webkit-box-orient:vertical;display:-webkit-box;-webkit-line-clamp:2;margin-top:19px">競技プログラミングの鉄則 (Compass Booksシリーズ)</div><div class="pickLayout2_advertiser pickLayout2_advertiser--medium" style="font-size:10px;color:#757575;text-align:left;overflow:hidden;white-space:nowrap;text-overflow:ellipsis">Amazon（アマゾン）</div><div class="pickLayout2_price pickLayout2_price--medium" style="color:#333;text-align:left;font-size:14px;margin-top:12px;margin-bottom:12px">&nbsp;</div></div><div class="pickLayout2_imgWrapper pickLayout2_imgWrapper--medium" style="padding:4px 0;position:relative;margin-left:16px;width:144px;height:144px;flex-shrink:0"><img alt="" class="pickLayout2_img" data-img="affiliate" height="144" src="https://m.media-amazon.com/images/I/51g2fFApKBL._SL500_.jpg" style="width:auto;height:auto;margin:auto; margin: auto;position:absolute;top:0;left:0;right:0;bottom:0;max-width:100%;max-height:100%" width="144"></div></div></a></article></div><p>&nbsp;</p></div><p>&nbsp;</p><p>&nbsp;</p><p><br>&nbsp;</p>
]]>
</description>
<link>https://ameblo.jp/tonakai0521/entry-12893826445.html</link>
<pubDate>Mon, 14 Apr 2025 12:52:34 +0900</pubDate>
</item>
<item>
<title>【解説】401 A AtCoder Beginner Contest</title>
<description>
<![CDATA[ <h2>AtCoder Beginner Contest 401&nbsp;A - Status Code</h2><p><b style="font-weight:bold;">解説</b></p><p>　整数の入力を受け取るときはint(input())で受け取りましょう</p><p>　input()は文字列です。int(input())にすることで文字列から整数に変換しています。</p><p>&nbsp;</p><p>　200以上299以下のときはSuccessを出力、それ以外の時はFailureを出力します</p><p>　出力するときはprint("出力したい文字列")を使います。</p><p>　""で囲むのを忘れないようにしましょう</p><p>&nbsp;</p><p>　下が実際のコードになります</p><main id="main"><p>---------------ACしたコード--------------</p><p><mark style="background-color:#bfebff;color:inherit;">#入力</mark></p><p>S = int(input())</p><p><br>if 200 &lt;= S &lt;= 299:<br>&nbsp; &nbsp; print("Success")<br>else:<br>&nbsp; &nbsp; print("Failure")</p><p>-------------------------------------------</p><p>&nbsp;</p></main><div class="ogpCard_root"><div class="ogpCard_root"><p>提出したコードのリンク</p></div></div><p>↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓</p><p>&nbsp;</p><div class="ogpCard_root"><article class="ogpCard_wrap" contenteditable="false" style="display:inline-block;max-width:100%"><a class="ogpCard_link" data-ogp-card-log="" href="https://atcoder.jp/contests/abc401/submissions/64726903" rel="noopener noreferrer" style="display:flex;justify-content:space-between;overflow:hidden;box-sizing:border-box;width:620px;max-width:100%;height:120px;border:1px solid #e2e2e2;border-radius:4px;background-color:#fff;text-decoration:none" target="_blank"><span class="ogpCard_content" style="display:flex;flex-direction:column;overflow:hidden;width:100%;padding:16px"><span class="ogpCard_title" style="-webkit-box-orient:vertical;display:-webkit-box;-webkit-line-clamp:2;max-height:48px;line-height:1.4;font-size:16px;color:#333;text-align:left;font-weight:bold;overflow:hidden">Submission #64726903 - AtCoder Beginner Contest 401</span><span class="ogpCard_description" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:1.6;margin-top:4px;color:#757575;text-align:left;font-size:12px">AtCoder is a programming contest site for anyone from beginners to experts. We hold weekly programming contests online.</span><span class="ogpCard_url" style="display:flex;align-items:center;margin-top:auto"><span class="ogpCard_iconWrap" style="position:relative;width:20px;height:20px;flex-shrink:0"><img alt="リンク" class="ogpCard_icon" height="20" loading="lazy" src="https://c.stat100.ameba.jp/ameblo/symbols/v3.20.0/svg/gray/editor_link.svg" style="position:absolute;top:0;bottom:0;right:0;left:0;height:100%;max-height:100%" width="20"></span><span class="ogpCard_urlText" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#757575;font-size:12px;text-align:left">atcoder.jp</span></span></span><span class="ogpCard_imageWrap" style="position:relative;width:120px;height:120px;flex-shrink:0"><img alt="" class="ogpCard_image" data-ogp-card-image="" height="120" loading="lazy" src="https://img.atcoder.jp/assets/atcoder.png" style="position:absolute;top:50%;left:50%;object-fit:cover;min-height:100%;min-width:100%;transform:translate(-50%,-50%)" width="120"></span></a></article></div><p>&nbsp;</p><div class="ogpCard_root">&nbsp;</div><p>&nbsp;</p><div class="ogpCard_root"><div class="pickCreative_root" style="font-size:0"><article class="pickCreative_wrap" contenteditable="false" style="display:inline-block;max-width:100%"><a class="pickCreative pickLayout2" data-aid="kzevP6tAcceZbIvitBc4W2" data-detail-setting="{&quot;show_price&quot;:false}" data-df-item-id="4297125218" data-img-size="medium" data-img-url="https://m.media-amazon.com/images/I/51Q+KKW3EyL._SL500_.jpg" data-item-id="AZ000001" data-layout-type="2" href="https://d.odsyms15.com/click?aid=kzevP6tAcceZbIvitBc4W2" id="kzevP6tAcceZbIvitBc4W2" style="background-color:#fff;border-radius:4px;box-sizing:border-box;display:block;max-width:100%;padding:4px 8px;text-decoration:none;width:450px;font-family:ヒラギノ角ゴ Pro W3, Hiragino Kaku Gothic Pro, ＭＳ Ｐゴシック, Helvetica, Arial, sans-serif;line-height:1;font-weight:normal;font-style:normal;word-break:break-all" target="_blank"><div class="pickLayout2_inner" style="display:flex"><div class="pickLayout2_info" style="flex:1 1 0%;overflow:hidden;min-width:56px"><div class="pickLayout2_title pickLayout2_title--medium" style="font-weight:bold;margin-bottom:8px;overflow:hidden;color:#333;text-align:left;white-space:normal;text-overflow:ellipsis;font-size:14px;line-height:1.3;max-height:3em;-webkit-box-orient:vertical;display:-webkit-box;-webkit-line-clamp:2;margin-top:19px">問題解決のための「アルゴリズム×数学」が基礎からしっかり身につく本</div><div class="pickLayout2_advertiser pickLayout2_advertiser--medium" style="font-size:10px;color:#757575;text-align:left;overflow:hidden;white-space:nowrap;text-overflow:ellipsis">Amazon（アマゾン）</div><div class="pickLayout2_price pickLayout2_price--medium" style="color:#333;text-align:left;font-size:14px;margin-top:12px;margin-bottom:12px">&nbsp;</div></div><div class="pickLayout2_imgWrapper pickLayout2_imgWrapper--medium" style="padding:4px 0;position:relative;margin-left:16px;width:144px;height:144px;flex-shrink:0"><img alt="" class="pickLayout2_img" data-img="affiliate" height="144" src="https://m.media-amazon.com/images/I/51Q+KKW3EyL._SL500_.jpg" style="width:auto;height:auto;margin:auto; margin: auto;position:absolute;top:0;left:0;right:0;bottom:0;max-width:100%;max-height:100%" width="144"></div></div></a><ul class="addShopLink_list" style="max-width:450px;padding:0;font-weight:bold;font-size:14px;font-family:Hiragino Kaku Gothic Pro;margin:0;list-style:none"><li class="addShopLink_listItem" style="display:block;width:100%;margin-top:8px"><a class="pickLink addShopLink_listItemLink" data-aid="icw1bFvNrq6IcOmnFPa217" data-df-item-id="4297125218" data-item-id="AZ000001" data-layout-type="101" href="https://d.odsyms15.com/click?aid=icw1bFvNrq6IcOmnFPa217" id="icw1bFvNrq6IcOmnFPa217" rel="noopener" style="display:flex;align-items:center;box-sizing:border-box;height:36px;padding:12px;padding-right:16px;color:#333;font-weight:bold;font-size:12px;text-decoration:none;background-color:#f8f8f8" target="_blank"><span class="addShopLink_listItemLinkShopName" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap">Amazon（アマゾン）</span><span class="addShopLink_listItemLinkShopMore" style="flex:1;word-break:keep-all;text-align:left">で詳細を見る</span><div class="addShopLink_listItemLinkArrow" style="display:inline-block;margin-left:auto;padding:5px;border-color:#757575;border-style:solid;border-top-width:0;border-right-width:2px;border-bottom-width:2px;border-left-width:0;transform:rotate(-45deg)"><div class="addShopLink_nothing" style="display:none">&nbsp;</div></div></a></li><li class="addShopLink_listItem" style="display:block;width:100%;margin-top:8px"><a class="pickLink addShopLink_listItemLink" data-aid="fQfhtYTzBC8pCy9Z9oaN25" data-df-item-id="azusa:10000143" data-item-id="RK000001" data-layout-type="101" href="https://d.odsyms15.com/click?aid=fQfhtYTzBC8pCy9Z9oaN25" id="fQfhtYTzBC8pCy9Z9oaN25" rel="noopener" style="display:flex;align-items:center;box-sizing:border-box;height:36px;padding:12px;padding-right:16px;color:#333;font-weight:bold;font-size:12px;text-decoration:none;background-color:#f8f8f8" target="_blank"><span class="addShopLink_listItemLinkShopName" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap">楽天市場</span><span class="addShopLink_listItemLinkShopMore" style="flex:1;word-break:keep-all;text-align:left">で詳細を見る</span><div data-eventlabel-end="1735570740" data-eventlabel-itemid="RK000001" data-eventlabel-start="1735484400" hidden style="background-color:#d91c0b;flex-shrink:0;font-size:10px;font-weight:bold;color:#fff;padding:4px 8px;border-radius:4px;margin:0 8px;box-sizing:border-box;width:-webkit-fit-content; width: -moz-fit-content; width: fit-content;line-height:1.2;max-width:5em;text-overflow:ellipsis;overflow:hidden;white-space:nowrap">${EVENT_LABEL_02_TEXT}</div><div class="addShopLink_listItemLinkArrow" style="display:inline-block;margin-left:auto;padding:5px;border-color:#757575;border-style:solid;border-top-width:0;border-right-width:2px;border-bottom-width:2px;border-left-width:0;transform:rotate(-45deg)"><div class="addShopLink_nothing" style="display:none">&nbsp;</div></div></a></li></ul></article></div><p>&nbsp;</p><div class="pickCreative_root" style="font-size:0"><article class="pickCreative_wrap" contenteditable="false" style="display:inline-block;max-width:100%"><a class="pickCreative pickLayout2" data-aid="D89ZTGaG7u9y3BPnuIugO5" data-detail-setting="{&quot;show_price&quot;:false}" data-df-item-id="B0BDZGDM9J" data-img-size="medium" data-img-url="https://m.media-amazon.com/images/I/51g2fFApKBL._SL500_.jpg" data-item-id="AZ000001" data-layout-type="2" href="https://d.odsyms15.com/click?aid=D89ZTGaG7u9y3BPnuIugO5" id="D89ZTGaG7u9y3BPnuIugO5" style="background-color:#fff;border-radius:4px;box-sizing:border-box;display:block;max-width:100%;padding:4px 8px;text-decoration:none;width:450px;font-family:ヒラギノ角ゴ Pro W3, Hiragino Kaku Gothic Pro, ＭＳ Ｐゴシック, Helvetica, Arial, sans-serif;line-height:1;font-weight:normal;font-style:normal;word-break:break-all" target="_blank"><div class="pickLayout2_inner" style="display:flex"><div class="pickLayout2_info" style="flex:1 1 0%;overflow:hidden;min-width:56px"><div class="pickLayout2_title pickLayout2_title--medium" style="font-weight:bold;margin-bottom:8px;overflow:hidden;color:#333;text-align:left;white-space:normal;text-overflow:ellipsis;font-size:14px;line-height:1.3;max-height:3em;-webkit-box-orient:vertical;display:-webkit-box;-webkit-line-clamp:2;margin-top:19px">競技プログラミングの鉄則 (Compass Booksシリーズ)</div><div class="pickLayout2_advertiser pickLayout2_advertiser--medium" style="font-size:10px;color:#757575;text-align:left;overflow:hidden;white-space:nowrap;text-overflow:ellipsis">Amazon（アマゾン）</div><div class="pickLayout2_price pickLayout2_price--medium" style="color:#333;text-align:left;font-size:14px;margin-top:12px;margin-bottom:12px">&nbsp;</div></div><div class="pickLayout2_imgWrapper pickLayout2_imgWrapper--medium" style="padding:4px 0;position:relative;margin-left:16px;width:144px;height:144px;flex-shrink:0"><img alt="" class="pickLayout2_img" data-img="affiliate" height="144" src="https://m.media-amazon.com/images/I/51g2fFApKBL._SL500_.jpg" style="width:auto;height:auto;margin:auto; margin: auto;position:absolute;top:0;left:0;right:0;bottom:0;max-width:100%;max-height:100%" width="144"></div></div></a></article></div><p>&nbsp;</p></div><p>&nbsp;</p><p>&nbsp;</p><p><br>&nbsp;</p>
]]>
</description>
<link>https://ameblo.jp/tonakai0521/entry-12893825769.html</link>
<pubDate>Mon, 14 Apr 2025 12:46:04 +0900</pubDate>
</item>
</channel>
</rss>
