question_id
stringlengths
6
6
content
stringlengths
1
27.2k
p02478
<a href="https://onlinejudge.u-aizu.ac.jp/resources/icpcooc2018/practice/C.pdf" target='_blank'>Problem is available from here.</a>
p00150
<H1>Twin Prime</H1> <p> Prime numbers are widely applied for cryptographic and communication technology. A twin prime is a prime number that differs from another prime number by 2. For example, (5, 7) and (11, 13) are twin prime pairs. </p> <p> In this problem, we call the greater number of a twin prime "size of the...
p00500
<H1>数圓おゲヌム (Unique number) </H1> <br/> <h2> 問題</h2> <p> JOI 君は友達ずゲヌムをするこずにしたこのゲヌムには N 人のプレむダヌが参加する1 回のゲヌムのルヌルは次のようなものである </p> <p> それぞれのプレむダヌは 1 以䞊 100 以䞋の奜きな敎数をカヌドに曞いお提出する各プレむダヌは自分ず同じ数を曞いた人が他にいなかった堎合自分の曞いた数ず同じ埗点を埗る自分ず同じ数を曞いた人が他にいた堎合は埗点を埗られない </p> <p> JOI 君たちはこのゲヌムを 3 回行った各プレむダヌが 3 回のゲヌムにおいお曞いた数が䞎えられたずき...
p01741
<p> マンハッタンでは道路がx 座暙たたはy 座暙が敎数のずころに通っおいるすぬけ君の家ずすめけ君の家はどちらも道路䞊にあり盎線距離(ナヌクリッド距離) はちょうど <var>d</var> であるすぬけ君の家からすめけ君の家たで道路に沿っお移動するずきの最短距離ずしお考えられる最倧倀を求めよ </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>d</var> &le; 10</li> <li><var>d</var> は小数点以䞋ちょうど䞉桁たで䞎えられる</li> </ul> <h2>Input</h2> <pre> <var>d</var> </p...
p00853
<H1><font color="#000">Problem I:</font> Enjoyable Commutation</H1> <p> Isaac is tired of his daily trip to his ofice, using the same shortest route everyday. Although this saves his time, he must see the same scenery again and again. He cannot stand such a boring commutation any more. </p> <p> One day, he decided to...
p03286
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an integer <var>N</var>, find the base <var>-2</var> representation of <var>N</var>.</p> <p>Here, <var>S</var> is the base <var>-2</var> representation of <var>N</var> when the following are all s...
p01311
<h1><font color="#000">Problem I:</font> 倏ぞの扉</h1> <p>な぀めは倧のねこ奜きである。な぀めの家ではずっずねこを飌っおおらず、ねこ奜きなな぀めはい぀も野良ねこず遊んでいた。しかし、今回な぀めは決心し、自分の家でねこを䞀匹飌うこずにした。な぀めはねこを家に迎え、レノンず名付けおかわいがり始めた。</p> <p>な぀めの家はたくさんの郚屋ず、それらを぀なぐたくさんの扉からなっおおり、扉は次の2皮類がある。</p> <dl> <dt>人間甚の普通の扉</dt> <dd>な぀めは開けるこずができるが、レノンが自分で開けるこずはできない。な぀めずレノンの䞡方が通るこ...
p03906
<span class="lang-en"> <p>Score : <var>1500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>The currency used in Takahashi Kingdom is <em>Myon</em>. There are <var>1</var>-, <var>10</var>-, <var>100</var>-, <var>1000</var>- and <var>10000</var>-Myon coins, and so forth. Formally, there are <v...
p02614
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a grid of <var>H</var> rows and <var>W</var> columns of squares. The color of the square at the <var>i</var>-th row from the top and the <var>j</var>-th column from the left <var>(1 \leq i \leq ...
p00629
<H1><font color="#000000">Problem 03:</font> Selecting Teams Advanced to Regional</H1> <p> 日本で毎幎開催される囜際倧孊察抗プログラミングコンテストのアゞア地区予遞に出堎するためには、厳しい囜内予遞を突砎しなければなりたせん。 </p> <p> 倧孊察抗ずは蚀っおも、぀の孊校から耇数のチヌムが参戊したす。そこで、できるだけ倚くの孊校がアゞア地区予遞に出堎できるように、突砎チヌムの遞抜には以䞋の遞抜ルヌルが適甚されたす </p> <p> 該圓チヌムを <i>A</i> ずし、成瞟の優秀な順番に次のルヌルを適甚したす </p> <...
p02244
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>8 Queens Problem</H1> <p>...
p00279
<H1>ハッピヌ゚ンド問題</H1> <p> 「ハッピヌ゚ンド問題」ず呌ばれる数孊の未解決問題に関連したプログラムを曞いおみたしょう。平面䞊に䞎えられた<var>N</var>個の点から、ちょうど<var>k</var>個の点を結んでできる凞倚角圢のうち、最も面積の小さいものを芋぀けるプログラムを䜜成しおください。ただし、N個の点の座暙を䞎えられた埌、質問ずしお凞倚角圢の角の個数<var>k</var>がいく぀か䞎えられたす。 </p> <p> 補足ハッピヌ゚ンド問題に぀いお<br/> 平面䞊にどの点も同じ盎線䞊に乗らないように<var>N</var>個の点を眮きたす。そのずき、どのように点を眮いおも、k個の点をう...
p01891
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]} }); </script> <script type="text/javascript" async src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <h1>A: キャベツ / Cabbage</h1> <h2>問題文</h2> <p> AOR むカちゃんは葉が $N$ 枚あ...
p00783
<H1><font color="#000">Problem D:</font> Napoleon's Grumble</H1> <p> Legend has it that, after being defeated in Waterloo, Napoleon Bonaparte, in retrospect of his days of glory, talked to himself "Able was I ere I saw Elba." Although, it is quite doubtful that he should have said this in English, this phrase is wide...
p01038
<h1>Problem B: Mountain Climbing</h1> <h2>Problem</h2> <p> なりよし君は山登りの蚈画を立おおいたす。蚈画はずおも倧切です。高原・盆地が倚いのか、峰・窪地が倚いのか、山腹があるのか、状況によっお甚意する荷物も倉わっおきたす。 </p> <p> なりよし君が持っおいる登山ガむドブックには、今回登山に利甚する道の䞀定の距離毎の暙高がスタヌト地点からゎヌル地点たで順に曞かれおいたす。 </p> <p> ガむドブックに曞かれおいる暙高をスタヌト地点からゎヌル地点たで順に <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <va...
p03005
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Takahashi is distributing <var>N</var> balls to <var>K</var> persons.</p> <p>If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received betw...
p01468
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], skipTags: ["script","noscript","style","textarea","code"], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?con...
p03455
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>AtCoDeer the deer found two positive integers, <var>a</var> and <var>b</var>. Determine whether the product of <var>a</var> and <var>b</var> is even or odd.</p> </section> </div> <div class="part"> <sec...
p01192
<H1><font color="#000"></font>Greedy, Greedy.</H1> <!-- Problem D--> <p> Once upon a time, there lived a dumb king. He always messes things up based on his whimsical ideas. This time, he decided to renew the kingdom’s coin system. Currently the kingdom has three types of coins of values 1, 5, and 25. He is thinking of...
p01487
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script> </script> <h2>Problem B: RabbitWalking </h2...
p03140
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given three strings <var>A, B</var> and <var>C</var>. Each of these is a string of length <var>N</var> consisting of lowercase English letters.</p> <p>Our objective is to make all these three st...
p03510
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>In a long narrow forest stretching east-west, there are <var>N</var> beasts. Below, we will call the point that is <var>p</var> meters from the west end Point <var>p</var>. The <var>i</var>-th beast fro...
p00296
<h1>バトンリレヌゲヌム</h1> <p> アカベ高校では、毎幎党校生埒が参加するゲヌムを行っおいたす。たず、校庭に <var>N</var> 人の党校生埒が円圢に䞊びたす。図のように、各生埒は 0 から <var>N</var>-1 たでの番号が曞かれたれッケンを付けおいたす。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_PCK2014_button" width="280"> </center> <br> <p> ゲヌムではバトンを本䜿い、最初はれッケン 0 番の生埒がバトンを持っおいたす。そこから、以...
p03843
<span class="lang-en"> <p>Score : <var>1900</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There is a tree with <var>N</var> vertices. The vertices are numbered <var>1</var> through <var>N</var>. For each <var>1 ≀ i ≀ N - 1</var>, the <var>i</var>-th edge connects vertices <var>a_i</var> and...
p02751
<span class="lang-en"> <p>Score : <var>900</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>We have a grid with <var>(2^N - 1)</var> rows and <var>(2^M-1)</var> columns. You are asked to write <var>0</var> or <var>1</var> in each of these squares. Let <var>a_{i,j}</var> be the number written ...
p02301
<H1>Diameter of a Convex Polygon</H1> <br/> <p> Find the diameter of a convex polygon <var>g</var>. In other words, find a pair of points that have maximum distance between them. </p> <H2>Input</H2> <pre> <var>n</var> <var>x<sub>1</sub></var> <var>y<sub>1</sub></var> <var>x<sub>2</sub></var> <var>y<sub>2</sub></va...
p00453
<H1> ぎょんぎょん川枡り </H1> <h2>問題</h2> <p> ある川で,䞀方の岞から石の䞊を次々ず飛び移っお反察偎の岞たで行くずいう少々危険なゲヌムがはやっおいる. </p> <br> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_hyonhyon1"> </center> <br> <p> 今,図 4-1 のように,石はマス目の䞊に存圚するず考える.行の数は n である. 図 4-1 では n = 5 である. </p> <p> このゲヌムでは,䞀方の岞から始めお,通垞のゞャンプたたは m 回以䞋の䞀行...
p02194
<h2>Zero AND Subsets</h2> <p>非負敎数の倚重集合<var>a_1,a_2,..,a_N</var>が䞎えられたす。</p> <p>この集合の空でない郚分集合であっお、倀のbitwiseANDが<var>0</var>になるものはいく぀ありたすか。</p> <p>答えを<var>10^9+7</var>で割った䜙りを求めおください。</p> <h3>入力</h3> <pre> <var>N</var> <var>a_1 a_2...a_N</var> </pre> <h3>出力</h3> <p>答えを<var>10^9+7</var>で割った䜙りを出力せよ。</p> <h3>制玄</h3> <ul> ...
p00003
<H1>Is it a Right Triangle?</H1> <p> Write a program which judges wheather given length of three side form a right triangle. Print "<span>YES</span>" if the given sides (integers) form a right triangle, "<span>NO</span>" if not so. </p> <H2>Input</H2> <p> Input consists of several data sets. In the first line, the ...
p01242
<H1><font color="#000">Problem I:</font> Revenge of Voronoi</H1> <p> A discrete Voronoi diagram is a derivation of a Voronoi diagram. It is represented as a set of pixels. Each of the generatrices lies on the center of some pixel. Each pixel belongs to the generatrix nearest from the center of the pixel in the sense ...
p02897
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given is an integer <var>N</var>.</p> <p>Takahashi chooses an integer <var>a</var> from the positive integers not greater than <var>N</var> with equal probability.</p> <p>Find the probability that <var>...
p03785
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Every day, <var>N</var> passengers arrive at Takahashi Airport. The <var>i</var>-th passenger arrives at time <var>T_i</var>.</p> <p>Every passenger arrived at Takahashi airport travels to the city by b...
p04040
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a large square grid with <var>H</var> rows and <var>W</var> columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the b...
p00900
<H1><font color="#000">Problem G: </font>Captain Q&prime;s Treasure</H1> <p> You got an old map, which turned out to be drawn by the infamous pirate &ldquo;Captain Q&rdquo;. It shows the locations of a lot of treasure chests buried in an island. </p> <p> The map is divided into square sections, each of which has a d...
p01612
<h2>瀟員旅行</h2> <h2>Problem Statement</h2> <p>あなたの䌚瀟には<var>n</var>人の瀟員が存圚する<var>m</var>個の瀟員<var>(a_i,b_i)</var>の組に぀いお<var>a_i</var>は<var>b_i</var>の䞊叞である</p> <p>瀟員<var>x</var>が瀟員<var>y</var>の実質的な䞊叞であるずは次のうち少なくずも䞀方が成り立぀こずをいう<br /></p> <ul class="list1" style="padding-left:16px;margin-left:16px"><li><var>x</var>が...
p01307
<h1><font color="#000">Problem E:</font> 足し算ゲヌム</h1> <p> ねこのファヌブルは足し算を甚いた簡単なゲヌムを思い぀き、同じくねこで友達のオヌドリヌず䞀緒にやっおみるこずにした。 </p> <p> ゲヌムのルヌルは次のようなものである。たず最初に、適圓な正の敎数を遞び、そこからスタヌトする。各プレヌダヌは、その数のうち隣り合う2぀の桁を遞択しお和を蚈算し、もずの2぀の数字ず眮き換える。たずえば、「1234」の十の䜍ず癟の䜍を遞ぶず、次の数は「154」ずなる。「5555」の十の䜍ず癟の䜍を遞んだ堎合は「5105」ずなる。このような操䜜を数が1桁になるたで亀互に繰り返し、操䜜が...
p03290
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>A programming competition site <em>AtCode</em> provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer <var>i</var> between <var>1</var> and...
p02878
<span class="lang-en"> <p>Score : <var>2200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have two indistinguishable pieces placed on a number line. Both pieces are initially at coordinate <var>0</var>. (They can occupy the same position.)</p> <p>We can do the following two kinds of oper...
p00845
<H1><font color="#000">Problem A:</font> How I Wonder What You Are!</H1> <p> One of the questions children often ask is "How many stars are there in the sky?" Under ideal conditions, even with the naked eye, nearly eight thousands are observable in the northern hemisphere. With a decent telescope, you may find many mo...
p01757
<p> 今幎も党囜プログラミング遞手暩倧䌚の時期がやっおきた党囜倧䌚の参加暩を賭けた地区倧䌚は <var>2<sup>n</sup></var> チヌムが1 察1 の勝ち残り匏トヌナメント方匏で察決する </p> <p> トヌナメント衚にはチヌム番号 <var>0, . . . 2<sup>n</sup> &minus; 1</var> が割り振られおおり1 回戊から <var>n</var> 回戊たでの察決手順は次の通りである </p> <ol> <li> 1 回戊ではチヌム番号が <var>l</var> のチヌムずチヌム番号が <var>l</var> + 1 のチヌムが察決する(<var>l...
p00516
<H1>問題 2:  投祚 (Vote) </H1> <br/> <h2>問題</h2> <p> 20XX幎に東京で䞖界的なスポヌツ倧䌚が開かれるこずになったプログラミングコンテストはスポヌツずしお䞖界で楜したれおおり競技ずしお採甚される可胜性がある採甚される競技を決める審査委員䌚に぀いお調べたずころ次のようなこずが分かった </p> <ul> <li> 審査委員䌚のために候補ずなる N 個の競技を面癜い方から順番に䞊べたリストが䜜成されたリストの䞊から i 番目には i 番目に面癜い競技が曞かれおいるそれを競技 i ずするさらに競技 i の開催に必芁な費甚 A<sub>i</sub> が曞かれおいる...
p00146
<H1>ルパン四䞖</H1> <p> 怪盗「ルパン四䞖」は䌚接藩士を末裔ずする矎女「富士峰子」より、䌚接若束垂に䌚接藩が残した軍資金が眠っおいるこずを聞かされる。ルパンの長幎の仲間である「石川越ェ門」の報告によれば、軍資金は千䞡箱に収められいく぀かの蔵に保管されおいる。蔵に芋匵りはいないが厳重に斜錠されおいる。しかし、越ェ門は圌が父から䌝授された秘䌝「鋌鉄斬り」の技を繰り出せば瞬時に蔵を砎れるずいう。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_lupin"> </center> <br/> <p> 残った問題...
p01184
<H1><font color="#000">Problem D:</font> International Party</H1> <p> Isaac H. Ives is attending an international student party (maybe for girl-hunting). Students there enjoy talking in groups with excellent foods and drinks. However, since students come to the party from all over the world, groups may not have a lan...
p03443
<span class="lang-en"> <p>Score : <var>2000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There is a bridge that connects the left and right banks of a river. There are <var>2 N</var> doors placed at different positions on this bridge, painted in some colors. The colors of the doors are rep...
p03013
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There is a staircase with <var>N</var> steps. Takahashi is now standing at the foot of the stairs, that is, on the <var>0</var>-th step. He can climb up one or two steps at a time.</p> <p>However, the t...
p00795
<H1><font color="#000">Problem H:</font> Co-occurrence Search</H1> <p> A huge amount of information is being heaped on WWW. Albeit it is not well-organized, users can browse WWW as an unbounded source of up-to-date information, instead of consulting established but a little out-of-date encyclopedia. However, you can ...
p01887
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script> </script> <h2>Pipe Fitter and the Fierce Dog...
p02252
<h1>Fractional Knapsack Problem</h1> <p>You have $N$ items that you want to put them into a knapsack of capacity $W$. Item $i$ ($1 \le i \le N$) has weight $w_i$ and value $v_i$ for the weight.</p> <p>When you put some items into the knapsack, the following conditions must be satisfied:</p> <ul> <li>The total value...
p02602
<span class="lang-en"> <p>Score: <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>M-kun is a student in Aoki High School, where a year is divided into <var>N</var> terms.<br/> There is an exam at the end of each term. According to the scores in those exams, a student is given a grade...
p03910
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>The problem set at <em>CODE FESTIVAL 20XX Finals</em> consists of <var>N</var> problems.</p> <p>The score allocated to the <var>i</var>-th <var>(1≩i≩N)</var> problem is <var>i</var> points.</p> <p>Takah...
p02317
<H1>Longest Increasing Subsequence</H1> <br/> <p> For a given sequence <var>A = {a<sub>0</sub>, a<sub>1</sub>, ... , a<sub>n-1</sub>}</var>, find the length of the longest increasing subsequnece (LIS) in <var>A</var>. </p> <p> An increasing subsequence of <var>A</var> is defined by a subsequence <var>{a<sub>i<sub>0<...
p02747
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>A Hitachi string is a concatenation of one or more copies of the string <code>hi</code>.</p> <p>For example, <code>hi</code> and <code>hihi</code> are Hitachi strings, while <code>ha</code> and <code>h...
p03855
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> cities. There are also <var>K</var> roads and <var>L</var> railways, extending between the cities. The <var>i</var>-th road bidirectionally connects the <var>p_i</var>-th and <var...
p01868
<!-- - - - - - begin nicebody - - - - - --> <script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]} }); </script> <script type="text/javascript" async src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <h1>D: スキャ...
p00280
<h1>テニス</h1> <p> ゞョり君ずダ゚さんは昌䌑みにテニスをしたす。ただし、昌䌑みは時間が限られおいるので、短い時間で終わるように、埗点に぀いお以䞋の぀のルヌルで行いたす。 </p> <ul> <li> 盞手が点以䞋のずきに先に点ずれば勝ち。</li> <li> 察の同点になったずきは、その盎埌に連続しお点ずった方が勝ち。</li> <li> 察の埌に双方が点ず぀ずったずきは匕き分け。</li> </ul> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_PCK2013_tennis" width=...
p03506
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given an integer <var>N</var>. Consider an infinite <var>N</var>-ary tree as shown below:</p> <div style="text-align: center;"> <img src="https://img.atcoder.jp/relay2/c76baa50b0acf2806268859772...
p03156
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You have written <var>N</var> problems to hold programming contests. The <var>i</var>-th problem will have a score of <var>P_i</var> points if used in a contest.</p> <p>With these problems, you would li...
p01491
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script> </script> <h2>Problem F: RabbitLunch </h2> ...
p03382
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Let <var>{\rm comb}(n,r)</var> be the number of ways to choose <var>r</var> objects from among <var>n</var> objects, disregarding order. From <var>n</var> non-negative integers <var>a_1, a_2, ..., a_n</...
p00957
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], skipTags: ["script","noscript","style","textarea","code"], processEscapes: true }}); </script> <script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config...
p01645
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [['\\(','\\)']] } }); </script> <script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script> <h1 class="ndoc-heading1">Problem L: The Return of FizzBuzz</h1> <p c...
p03678
<span class="lang-en"> <p>Score : <var>1100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We will call a string that can be obtained by concatenating two equal strings an <em>even</em> string. For example, <code>xyzxyz</code> and <code>aaaaaa</code> are even, while <code>ababab</code> and <...
p04017
<span class="lang-en"> <p>Score : <var>700</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p><var>N</var> hotels are located on a straight line. The coordinate of the <var>i</var>-th hotel <var>(1 \leq i \leq N)</var> is <var>x_i</var>.</p> <p>Tak the traveler has the following two personal pri...
p01215
<H1><font color="#000">Problem I:</font> Pythagoraslope</H1> <p> Alice, your girlfriend, is a student at an art school. She is in the final year, and now working hard to build a facture for fulfilling the requirement to graduate. Her work is a large pinball with many straight slopes. Before starting to build, she has...
p03228
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>In the beginning, Takahashi has <var>A</var> cookies, and Aoki has <var>B</var> cookies. They will perform the following operation alternately, starting from Takahashi:</p> <ul> <li>If the number of coo...
p02593
<span class="lang-en"> <p>Score : <var>2200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given positions <var>(X_i, Y_i)</var> of <var>N</var> enemy rooks on an infinite chessboard. No two rooks attack each other (at most one rook per row or column).</p> <p>You're going to replace ...
p02069
<style type="text/css"> blockquote { font-family: Menlo, Monaco, "Courier New", monospace; display: block; margin: 10px 0 10px 30px; font-size: 16px; line-height: 18px; white-space: pre; white-space: pre-wrap; word-break: break-all; word-wrap: ...
p00054
<H1>小数䜍の和</H1> <p> <var>a</var>, <var>b</var>, <var>n</var> は、いずれも正の敎数であるずしたす。分数 <var>a</var> / <var>b</var> の小数第 <var>i</var> 䜍の数を <var>f(i)</var> ずしたす (0 &le; <var>f(i)</var> &le; 9)。このずき、<var>i = 1</var> から <var>n</var> たでの <var>f(i)</var> の和を <var>s</var> ずしたす。<br/> <br/> <var>s = f(1) + f(2) +</var> ... <var>+...
p02439
<h1>Min-Max</h1> <p> For given three integers $a, b, c$, print the minimum value and the maximum value. </p> <h2>Input</h2> <p> The input is given in the following format. </p> <pre> $a \; b \; c\;$ </pre> <p> Three integers $a, b, c$ are given in a line. </p> <h2>Output</h2> <p> Print the minimum and max...
p00404
<h1>床</h1>   <p> ヒデペ博士の家の床には正方圢のタむルが敷き぀められおいたす。芞術に造詣が深いヒデペ博士は、赀、黄、青の塗料を䜿っおタむルに色を塗るこずにしたした。はじめに郚屋の適圓なタむルをひず぀遞び、以䞋の方法で色を塗っおいきたす。 </p> <ul> <li>タむルを塗る色を、赀図の番号、黄図の番号、青図の番号の順に倉えおいき、青の次はたた赀から始める。</li> <li>すでに色を塗った領域の隣に正方圢を远加し、そこに色を塗る。それらを合わせた領域が長方圢になるようにする。正方圢を远加する方向は、東、北、西、南の順に倉えおいき、南の次はたた東から始める図では、䞊方向が北、右方向が東で...
p00111
<H1>博士の暗号</H1> <p> 博 士 : ?D-C'KOPUA </p> <p> ピヌタヌ : どうしたんですか、デビッド博士? わけのわからないこずを叫ぶのにはもう慣れたしたが、 今日は文章にすらなっおいたせんよ。 </p> <p> 博 士 : ほれ。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_memorableCodes1"> </center> <br/> <p> ピヌタヌ : なんですか? この衚は......ああ、予遞の問題にこんなのがありたした。衚を䜿っお文字を眮き換え...
p00541
<h2>城壁 (Rampart)</h2> <p> 歎史孊者である JOI 教授はか぀お存圚した IOI 王囜に぀いお研究しおいる </p> <p> 過去の調査によるずIOI 王囜は瞊 <var>H</var> 行暪 <var>W</var> 列のマスに区切られた長方圢の圢をしおいたIOI 王囜の銖郜は防衛のために城壁で囲われおいた </p> <p> IOI 王囜の銖郜を囲う城壁は次のような圢をしおいる城壁には倧きさず呌ばれる倀が定たっおいる倧きさ <var>s</var> (<var>s</var> &ge; 3) の城壁ずは<var>s</var> &times; <var>s</var> の正方圢...
p02086
<h1>I: Palindrome Compliment</h1> <h2>問題文</h2> <p>小池くんはチヌムメむトをよく耒めたす。 圌はチヌムメむトである束厎くんを文字列 $S$ で耒めたす。その圢匏は以䞋の条件を満たしたす。</p> <ul> <li>$Hoge, Zaki, O$ は小文字アルファベットのみからなる文字列</li> <li>$S = Hoge + Zaki + Hoge + O$ ($+$ は文字列の結合を衚す)</li> <li>$S$ は回文</li> </ul> <p>小池くんは$Hoge$の長さを$N$ずしたずきに、束厎くんの耒め方が䜕通りあるのか気になりたした。 3人目のチヌムメンバヌにしおr...
p00812
<H1><font color="#000">Problem B:</font> Equals are Equals</H1> <p> Mr. Simpson got up with a slight feeling of tiredness. It was the start of another day of hard work. A bunch of papers were waiting for his inspection on his desk in his office. The papers contained his students' answers to questions in his Math class...
p01700
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script> <!-- begin en only --> <!--<...
p01350
<H1>Problem B: Carrot Tour </H1> <p> うさぎがある囜を旅行しおいる. この囜には1 から<i>n</i> の番号が぀いた<i>n</i> 個の郜垂があり, うさぎは今郜垂1にいる. 郜垂<i>i</i> は座暙平面䞊の1 点(<i>x<sub>i</sub></i>, <i>y<sub>i</sub></i>) ずみなす. </p> <p> うさぎは以䞋の条件をみたすように旅をする. </p> <ul> <li> 移動経路は折れ線であり, その各郚分は異なる2 郜垂を結ぶ線分でなければならない.</li> <li> 移動経路の党長は<i>r</i> 以䞋でなければならない. 経路のうち重...
p02985
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given a tree with <var>N</var> vertices and <var>N-1</var> edges. The vertices are numbered <var>1</var> to <var>N</var>, and the <var>i</var>-th edge connects Vertex <var>a_i</var> and <var>b_i...
p03697
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given two integers <var>A</var> and <var>B</var> as the input. Output the value of <var>A + B</var>.</p> <p>However, if <var>A + B</var> is <var>10</var> or greater, output <code>error</code> in...
p00668
<H1>Problem J: The Incubator</H1> <p> サラリヌマンの朝は早い。゚リヌトコヌスを進み䞀流䌁業に入瀟しお新人ずいう肩曞きからも卒業する頃、僕に䞋った蟞什は未開の惑星における営業掻動だった。蟺鄙な土地での䞍䟿な生掻を匷いられおいるが、䞀応は巊遷でなく栄転であり、その蚌拠に絊料もぐんず䞊がっおいる - こんな堎所では金なんお䜿いようもないのだけど。近幎僕たちが盎面しおいる宇宙芏暡の゚ネルギヌ䞍足に察応するため、特定の生物皮の個䜓から莫倧な゚ネルギヌを生成するテクノロゞヌが開発された。その特定の生物皮ずいうのが、この蟺鄙な惑星の固有皮なのだ。この生物が絶滅しないように保護し぀぀、適床に゚ネルギヌを...
p02655
<span class="lang-en"> <p>Score : <var>1200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have <var>N</var> boxes numbered <var>1</var> to <var>N</var>, and <var>M</var> balls numbered <var>1</var> to <var>M</var>. Currently, Ball <var>i</var> is in Box <var>A_i</var>.</p> <p>You can do ...
p03947
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Two foxes Jiro and Saburo are playing a game called <em>1D Reversi</em>. This game is played on a board, using black and white stones. On the board, stones are placed in a row, and each player places a ...
p00392
<h1>Common-Prime Sort</h1> <p> You are now examining a unique method to sort a sequence of numbers in increasing order. The method only allows swapping of two numbers that have a common prime factor. For example, a sequence [6, 4, 2, 3, 7] can be sorted using the following steps. <br/> <span>Step 0: 6 4 2 3 7</span> ...
p00238
<!-- <p> 䞉床の飯よりゲヌム奜きのだいご君は暇さえあればゲヌムばかりしおいたした。ですが、だいご君も高校幎生。クラスはもう受隓モヌドに入っおいたす。受隓勉匷をするからには、圓然ゲヌムで遊べる時間が短くなっおしたいたす。たずは1日に勉匷をする時間を決めお、残った時間をゲヌムなどに䜿うこずにしたしたが、だいご君は今たで蚈画を守れたためしがありたせんでした。芋かねたあなたは、だいご君の勉匷時間を管理するプログラムを曞くこずにしたした。 </p> 1日にやらなければならない勉匷の目暙時間をt、勉匷を開始した時刻をs、終了した時刻をfずおきたす。 --> <p> 勉匷を開始した時刻ず終了した時刻の情報を基に、1日で勉匷した...
p02205
<h2>たしざんひきざん (Calculation Training)</h2> <p>square1001 君は E869120 君に、誕生日プレれントずしお二぀の数字 $A$ ず $B$ をプレれントしたした。</p> <p>E869120 君はこの二぀の数字を䜿っお、蚈算トレヌニングをするこずにしたした。</p> <p>具䜓的には、E869120君は次の操䜜をちょうど $N$ 回これらの数に行いたす。</p> <ul> <li>奇数回目の操䜜のずき、$A$ を $A-B$ で眮き換える</li> <li>偶数回目の操䜜のずき、$B$ を $A+B$ で眮き換える</li> </ul> <br> <p>E8691...
p03044
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a tree with <var>N</var> vertices numbered <var>1</var> to <var>N</var>. The <var>i</var>-th edge in the tree connects Vertex <var>u_i</var> and Vertex <var>v_i</var>, and its length is <var>w_i...
p01079
<h1>Problem H: Hogemon Get</h1> <h2>Problem</h2> <p> がっちょ君は人気のゲヌムHogemon Getに熱䞭しおいる。がっちょ君が䜏んでいる䌚接囜はそれぞれ1から<var>N</var>の番号が぀いおいる<var>N</var>個の町からなる。たた、䌚接囜には<var>M</var>本の道があり、すべおの道は異なる2぀の町を結んでいる。がっちょ君は道を双方向に移動するこずができるが、道以倖を通っお、ある町から別の町に行くこずはできない。</p> <p> Hogemon Getでは、町<var>i</var>でボヌルを<var>d<sub>i</sub></var>個入手する...
p01583
<H1><font color="#000">Problem C:</font> Craftsman</H1> <p> Takeshi, a famous craftsman, accepts many offers from all over Japan. However, the tools which he is using now has become already too old. So he is planning to buy new tools and to replace the old ones before next use of the tools. Some offers may incur him ...
p03414
<span class="lang-en"> <p>Score : <var>1100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given a directed graph with <var>N</var> vertices and <var>M</var> edges. The vertices are numbered <var>1, 2, ..., N</var>, and the edges are numbered <var>1, 2, ..., M</var>. Edge <var>i</var...
p01429
<script type="text/javascript" src="./varmath.js" charset="UTF-8"></script> <h2>問題文</h2> <p> 䞖の䞭の少女たちはキュゥべえず契玄し願いを叶えおもらいそれずひきかえに魔法少女ずなる䜿う魔法の圢・効果は願いに匷く圱響を受ける魔法少女<i>さやか</i>ちゃんは最近キュゥべえず契玄した新米魔法少女である<i>さやか</i>の願いは「事故のため指が動かなくなり音楜を挔奏するのを諊めおいた男の子を助けるこず」であったので䜜る魔方陣は音笊が茪の䞊に䞊んだ圢をしおいる </p> <p><i>さやか</i>は <var>N</var> 個...
p03101
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>H</var> rows and <var>W</var> columns of white square cells.</p> <p>You will choose <var>h</var> of the rows and <var>w</var> of the columns, and paint all of the cells contained in those...
p01096
<h3>Daruma Otoshi</h3> <p> You are playing a variant of a game called "Daruma Otoshi (Dharma Block Striking)". </p> <p> At the start of a game, several wooden blocks of the same size but with varying weights are stacked on top of each other, forming a tower. Another block symbolizing Dharma is placed atop. You have ...
p03551
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is <code>YES</code> or <code>NO</code>.</p> <p>When he checked the detailed status of the submissio...
p02710
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>We have a tree with <var>N</var> vertices numbered <var>1</var> to <var>N</var>. The <var>i</var>-th edge in this tree connects Vertex <var>a_i</var> and <var>b_i</var>. Additionally, each vertex is pa...
p03802
<span class="lang-en"> <p>Score : <var>1200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke loves flags.</p> <p>Snuke is placing <var>N</var> flags on a line.</p> <p>The <var>i</var>-th flag can be placed at either coordinate <var>x_i</var> or coordinate <var>y_i</var>.</p> <p>Snuke thi...
p00687
<H1> Unable Count</H1> <BLOCKQUOTE> <P><I>I would, if I could,<BR> If I couldn't how could I?<BR> I couldn't, without I could, could I?<BR> Could you, without you could, could ye?<BR> Could ye? could ye?<BR> Could you, without you could, could ye?</I></P></BLOCKQUOTE> <P>It is true, as this old rhyme say...
p01995
<h2>G: 回文郚分列 (Palindromic Subsequences)</h2> <h3>問題</h3> <p>英小文字のみからなる文字列 <var>S</var> が䞎えられるので、この文字列 <var>S</var> の<b>連続ずは限らない</b>郚分列であっお、回文であるものは䜕皮類あるかを求めおください。</p> <p>ここで、<var>S</var> の連続ずは限らない郚分列ずは、元の文字列 <var>S</var> から <b><var>1</var> 文字以䞊</b> <var>|S|</var> 文字以䞋を任意に遞択し (遞択するそれぞれの文字の䜍眮は非連続でも良い)、それらを元の順番通りに連結させお...
p02340
<!--<h1>写像12盾 その10:ボヌルに区別なし・箱に区別なし・入れ方に制限なし</h1>--> <h1>Balls and Boxes 10</h1> <table border=""> <tr><th>Balls</th><th>Boxes</th><th>Any way</th><th>At most one ball</th><th>At least one ball</th></tr> <tr><th>Distinguishable</th><th>Distinguishable</th><td>1</td><td>2</td><td>3</td></tr> <tr><th>Indistinguisha...
p03223
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given <var>N</var> integers; the <var>i</var>-th of them is <var>A_i</var>. Find the maximum possible sum of the absolute differences between the adjacent elements after arranging these integers...
p03389
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given three integers <var>A</var>, <var>B</var> and <var>C</var>. Find the minimum number of operations required to make <var>A</var>, <var>B</var> and <var>C</var> all equal by repeatedly perfo...
p02961
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Jumbo Takahashi will play golf on an infinite two-dimensional grid.</p> <p>The ball is initially at the origin <var>(0, 0)</var>, and the goal is a grid point (a point with integer coordinates) <var>(X,...