question_id
stringlengths
6
6
content
stringlengths
1
27.2k
p03411
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>On a two-dimensional plane, there are <var>N</var> red points and <var>N</var> blue points. The coordinates of the <var>i</var>-th red point are <var>(a_i, b_i)</var>, and the coordinates of the <var>i<...
p03105
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Takahashi likes the sound when he buys a drink from a vending machine.</p> <p>That sound can be heard by spending <var>A</var> yen (the currency of Japan) each time.</p> <p>Takahashi has <var>B</var> ye...
p01138
<!-- begin en only --> <h3><U>Osaki</U></h3> <!-- end en only --> <!-- begin ja only --> <h3><U>大崎</U></h3> <!-- end ja only --> <!-- begin en only --> <p> English text is not available in this practice contest. </p> <!-- end en only --> <!-- begin ja only --> <p> 山手線は東京 23 区内に敷設されている環状鉄道路線である.総路線距離は 34.5km であり,1 ...
p03555
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given a grid with <var>2</var> rows and <var>3</var> columns of squares. The color of the square at the <var>i</var>-th row and <var>j</var>-th column is represented by the character <var>C_{ij}...
p01568
<h1>Repairing</h1> <p>In the International City of Pipe Construction, it is planned to repair the water pipe at a certain point in the water pipe network. The network consists of water pipe segments, stop valves and source point. A water pipe is represented by a segment on a 2D-plane and intersected pair of water pip...
p01092
<h2>Development of Small Flying Robots</h2> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_ICPCDomestic2015_H" align="right" width="300"> <p> You are developing small flying robots in your laboratory. </p> <p> The laboratory is a box-shaped building with <i>K</i> levels, each numbered 1 through <i...
p03806
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Dolphin is planning to generate a small amount of a certain chemical substance C.<br/> In order to generate the substance C, he must prepare a solution which is a mixture of two substances A and B in th...
p00729
<h1><font color="#000">Problem B:</font> Analyzing Login/Logout Records</h1> <!-- end en only --> <p> You have a computer literacy course in your university. In the computer system, the login/logout records of all PCs in a day are stored in a file. Although students may use two or more PCs at a time, no one can lo...
p02714
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a string <var>S</var> of length <var>N</var> consisting of <code>R</code>, <code>G</code>, and <code>B</code>.</p> <p>Find the number of triples <var>(i,~j,~k)~(1 \leq i &lt; j &lt; k \leq N)</v...
p00379
<h1>Dudeney Number</h1>   <p> A Dudeney number is a positive integer for which the sum of its decimal digits is equal to the cube root of the number. For example, $512$ is a Dudeney number because it is the cube of $8$, which is the sum of its decimal digits ($5 + 1 + 2$). </p> <p> In this problem, we think of a ty...
p02344
<H1>Weighted Union Find Trees</H1> <p> There is a sequence $A = a_0, a_1, ..., a_{n-1}$. You are given the following information and questions. </p> <ul> <li>relate$(x, y, z)$: $a_y$ is greater than $a_x$ by $z$</li> <li>diff$(x, y)$: report the difference between $a_x$ and $a_y$ $(a_y - a_x)$</li> </ul> <H2>Input...
p01991
<h2>C: な◯りカット (Namo.. Cut)</h2> <h3>問題</h3> <p>-謎の巨大クラゲ、 コードネーム「な◯り」を討伐せよ-</p> <p> 「な◯り」は非常に生命力が強いため、素早く切断し続けなければ、あっという間に復活してしまう。 我々は、「な◯り」をどのように切断するのが効率良いのか、日々試行錯誤している。 その過程で、あなた方プログラマの手が必要になった。 </p> <p> 「な◯り」は <var>N</var> 頂点と <var>N</var> 辺からなる連結な無向グラフで表現できる。 以降、各頂点が <var>1</var> から <var>N</var> の異なる数で名前付けられていると...
p00683
<H1>A Simple Offline Text Editor</H1> <P>A text editor is a useful software tool that can help people in various situations including writing and programming. Your job in this problem is to construct an offline text editor, i.e., to write a program that first reads a given text and a sequence of editing commands and f...
p00396
<h2>Playing with Stones</h2> <p> Koshiro and Ukiko are playing a game with black and white stones. The rules of the game are as follows: </p> <ol> <li> Before starting the game, they define some small areas and place "one or more black stones and one or more white stones" in each of the areas. </li> <li> K...
p03943
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Two students of AtCoder Kindergarten are fighting over candy packs.</p> <p>There are three candy packs, each of which contains <var>a</var>, <var>b</var>, and <var>c</var> candies, respectively.</p> <p>...
p02651
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are two persons, numbered <var>0</var> and <var>1</var>, and a variable <var>x</var> whose initial value is <var>0</var>. The two persons now play a game. The game is played in <var>N</var> rounds...
p02201
<h2>増えるE869120君 (Ninja E869120)</h2> <p>E869120君は分身が得意です。</p> <p>ここに、$N$ 人のパ研部員がいます。しかし、このうちの何人かが E869120 君かもしれません。</p> <p>そこで、あなたは $N$ 人全てのパ研部員に名前を聞きました。その結果、$N$ 人の部員はそれぞれ $S_1, S_2, S_3, \dots, S_N$ と名乗りました。</p> <p>E869120 君は何人に分身していたでしょうか?ただし、全てのパ研部員は正直に自分の名前を答えるものとします。</p> <h3>入力</h3> <p>入力は以下の形式で標準入力から与えられる。</p> <...
p01587
<H1><font color="#000">Problem G:</font> Riffle Swap</H1> <p> You have a deck of 2<sup><i>N</i></sup> cards (1 &le; <i>N</i> &le; 1000000) and want to have them shuffled. </p> <p> The most popular shuffling technique is probably the riffle shuffle, in which you split a deck into two halves, place them in your left a...
p03040
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There is a function <var>f(x)</var>, which is initially a constant function <var>f(x) = 0</var>.</p> <p>We will ask you to process <var>Q</var> queries in order. There are two kinds of queries, update q...
p03410
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given two integer sequences, each of length <var>N</var>: <var>a_1, ..., a_N</var> and <var>b_1, ..., b_N</var>.</p> <p>There are <var>N^2</var> ways to choose two integers <var>i</var> and <var...
p02128
<h1>Problem E: Light</h1> <h2>Problem</h2> <p> $W \times H$ の二次元のマス上に$N$個の街灯がある。<br> がっちょ君は$(1,1)$からスタートして$(W,H)$に行きたい。<br> がっちょ君は暗いところが怖いので、街灯により明るくなっているマスしか歩きたくない。<br> 最初、すべての街灯はその街灯のあるマスのみを明るくしている。<br> そこで、がっちょ君は好きな街灯$i$に対してコスト$r_i$を設定することにした。なお、コストを設定しない街灯があってもよい。<br> 街灯$i$はコスト$r_i$を消費することにより、その街灯を中心にマンハッタン距離で$r_i...
p00115
<h1>宇宙船 UAZ アドバンス号</h1> <p> 恒星歴 2005.11.5。あなたは宇宙船 UAZ アドバンス号の艦長として敵の宇宙船と交戦しようとしています。 幸い敵の宇宙船はまだこちらに気付かずに静止しています。また、すでに敵の宇宙座標は判明しており強力な直線のビームを放つ「フェザー砲」は発射準備を完了しています。あとは、発射命令を出すばかりです。 </p> <p> ところが、宇宙空間には、敵の設置したエネルギーバリアが存在しています。バリアは三角形をしており「フェザー砲」のビームをはね返してしまいます。また、ビームがバリアに当たれば敵に気付かれて逃げられてしまいます。事前に命中すると判定できなければ、発射命...
p02082
<h1>E: Expensive Function</h1> <h2>問題文</h2> <p>数列$a$と非負整数上の関数$f(x)$が以下のように定義されています。</p> <ul> <li>$a_1 = 0$</li> <li>$a_i = (a_{i-1} \times p + q) \bmod M (i \geq2)$</li> <li>$f(x) = x \mbox{ XOR } a_1 \mbox{ XOR } a_2 \mbox{ XOR } ... \mbox{ XOR } a_{10^8}$ </li> </ul> <p>松崎くんが計算すると、$f(s) = t$ でした。 非負整数 $y$ が与えられるので、$...
p02578
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p><var>N</var> persons are standing in a row. The height of the <var>i</var>-th person from the front is <var>A_i</var>.</p> <p>We want to have each person stand on a stool of some heights - at least zero...
p00545
<h1>JOI国のお散歩事情 (Walking in JOI Kingdom)</h1> <h2> 問題</h2> <p> JOI 国には東西に走る 1 本の十分に長い道路がある.JOI 国の王宮が道路沿いにあり,JOI 国における道路沿いの位置は整数 A で表される.A = 0 のときは王宮の位置を表す.A > 0 のときは,王宮から東へ A メートル進んだ位置を表す.A < 0 のときは,王宮から西へ -A メートル進んだ位置を表す. </p> <p> JOI 国の道路沿いには N 軒の家があり,家には西から順に 1 から N までの番号が付けられている.JOI 国には N 人の国民がいて,国民には 1 から N ま...
p01704
<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> <meta http-equiv="X-UA-Compatibl...
p03739
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given an integer sequence of length <var>N</var>. The <var>i</var>-th term in the sequence is <var>a_i</var>. In one operation, you can select a term and either increment or decrement it by one....
p00816
<H1><font color="#000">Problem F:</font> Shredding Company</H1> <p> You have just been put in charge of developing a new shredder for the Shredding Company. Although a ``normal'' shredder would just shred sheets of paper into little pieces so that the contents would become unreadable, this new shredder needs to have t...
p03693
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>AtCoDeer has three cards, one red, one green and one blue.<br/> An integer between <var>1</var> and <var>9</var> (inclusive) is written on each card: <var>r</var> on the red card, <var>g</var> on the gr...
p02981
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p><var>N</var> of us are going on a trip, by train or taxi.</p> <p>The train will cost each of us <var>A</var> yen (the currency of Japan).</p> <p>The taxi will cost us a total of <var>B</var> yen.</p> <p...
p01354
<H1>Problem F: The Castle</H1> <p> 待ち伏せていた敵を見事撃破したうさぎは, 主人公を敵の城内に進めることに成功した. 主人公が城の地下牢に捕らわれていたねこたちを解放したところ, 彼らのうちの何匹かが主人公の力になってくれることになった. </p> <p> ねこたちの話では, 城の奥にいる魔王に辿りつくには1 番から<i>n</i> 番の<i>n</i> 個の部屋をこの順に通り抜けることになるが, 各部屋には1 体ずつ敵が待ち受けていて逐一倒していかなければならないという. 仲間になった<i>m</i>匹のねこそれぞれについて, 各部屋の敵それぞれに対する勝率が分かっており, 主人公はこ...
p03369
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs <var>700</var> yen (the currency of Japan), plus <var>100</var> yen for each kind of topping (boiled egg, sliced pork, green onions).</p> <p>...
p01641
<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 H: Brainf*ck</h1> <p class="ndoc-to...
p00953
<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 H Animal Companion in...
p03386
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Print all the integers that satisfies the following in ascending order:</p> <ul> <li>Among the integers between <var>A</var> and <var>B</var> (inclusive), it is either within the <var>K</var> smallest i...
p01211
<H1><font color="#000">Problem E:</font> Spirograph</H1> <p> Some of you might have seen instruments like the figure below. </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_spirograph1"> <p>Figure 1: Spirograph</p> </center> <p> There are a fixed circle (indicated by <i>A</i> in the fig...
p04013
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Tak has <var>N</var> cards. On the <var>i</var>-th <var>(1 \leq i \leq N)</var> card is written an integer <var>x_i</var>. He is selecting one or more cards from these <var>N</var> cards, so that the av...
p00050
<H1>りんごと桃</H1> <p> 福島県は果物の産地としても有名で、その中でも特に桃とりんごは全国でも指折りの生産量を誇っています。ところで、ある販売用の英文パンフレットの印刷原稿を作ったところ、手違いでりんごに関する記述と桃に関する記述を逆に書いてしまいました。 </p> <p> あなたは、apple と peach を修正する仕事を任されましたが、なにぶん面倒です。1行の英文を入力して、そのなかの apple という文字列を全て peach に、peach という文字列を全てapple に交換した英文を出力するプログラムを作成してください。 </p> <H2>Input</H2> <p> 英文(半角英数字、空白...
p02597
<span class="lang-en"> <p>Score : <var>400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>An altar enshrines <var>N</var> stones arranged in a row from left to right. The color of the <var>i</var>-th stone from the left <var>(1 \leq i \leq N)</var> is given to you as a character <var>c_i</va...
p00400
<h1>アスキー文字</h1>   <p> コンピュータの内部ではすべての情報が数値として扱われています。たとえば、アスキーコードでは、アルファベットの大文字Aに数値の65が割り当てられています。同様にアルファベットの大文字Bに66、Cに67というように、AからZには連続してそれぞれ65から90が割り当てられています。また、アスキーコードでは、アルファベットの小文字aに97が割り当てられています。同様にアルファベットの小文字bに98、cに99というように、aからzには連続してそれぞれ97から122が割り当てられています。 </p> <p> 与えられたアスキーコードの数値が、アルファベットの大文字と小文字のどちらを表すか判定する...
p02313
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>Area of Intersection between Two Circles</H...
p00284
<h1>無限急行</h1> <p> ムゲン鉄道のムゲン線には無限個の駅があります。駅には …, -3, -2, -1, 0, 1, 2, 3, … と番号が振られていて、各駅は数直線上の整数と同じ順番で隣り合っています。あなたはいま、ある番号の駅から電車に乗り、それより大きな番号の駅に向かおうとしています。 </p> <p> ムゲン線には無限種類の快速電車が走っています。それらは 0 級快速、1 級快速、2 級快速、3 級快速、… のように番号で呼ばれています。<var>n</var> 級快速の電車は、2<var><sup>n</sup></var> の倍数の番号の駅に停車します。たとえば、1級快速は駅 …, -4, -2...
p03851
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Joisino is about to compete in the final round of a certain programming competition. In this contest, there are <var>N</var> problems, numbered <var>1</var> through <var>N</var>. Joisino knows that it ...
p02743
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Does <var>\sqrt{a} + \sqrt{b} &lt; \sqrt{c}</var> hold?</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li><var>1 \leq a, b, c \leq 10^9</var></li> <li>All values in input a...
p03502
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>An integer <var>X</var> is called a Harshad number if <var>X</var> is divisible by <var>f(X)</var>, where <var>f(X)</var> is the sum of the digits in <var>X</var> when written in base <var>10</var>.</p>...
p01495
<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 J: SolveMe </h2> <p>...
p03152
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Consider writing each of the integers from <var>1</var> to <var>N \times M</var> in a grid with <var>N</var> rows and <var>M</var> columns, without duplicates. Takahashi thinks it is not fun enough, and...
p03447
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You went shopping to buy cakes and donuts with <var>X</var> yen (the currency of Japan).</p> <p>First, you bought one cake for <var>A</var> yen at a cake shop. Then, you bought as many donuts as possibl...
p01180
<H1><font color="#000"></font>The Closest Circle</H1> <p> You are given <i>N</i> non-overlapping circles in xy-plane. The radius of each circle varies, but the radius of the largest circle is not double longer than that of the smallest. </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_cl...
p03017
<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> squares arranged in a row, numbered <var>1, 2, ..., N</var> from left to right. You are given a string <var>S</var> of length <var>N</var> consisting of <code>.</code> and <code>#...
p02256
<H1>Greatest Common Divisor</H1> <p> Write a program which finds the greatest common divisor of two natural numbers <i>a</i> and <i>b</i> </p> <H2>Input</H2> <p> <i>a</i> and <i>b</i> are given in a line sparated by a single space. </p> <H2>Output</H2> <p> Output the greatest common divisor of <i>a</i> and <i>b</...
p01883
<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>Parentheses</h2> <p> Dave love...
p00791
<H1><font color="#000">Problem D:</font> Trapezoids</H1> <p> If you are a computer user, you should have seen pictures drawn with ASCII characters. Such a picture may not look as good as GIF or Postscript pictures, but is much easier to handle. ASCII pictures can easily be drawn using text editors, and can convey gra...
p03914
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> towns in Takahashi Kingdom. They are conveniently numbered <var>1</var> through <var>N</var>.</p> <p>Takahashi the king is planning to go on a tour of inspection for <var>M</var>...
p01929
<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> <h3>へやわり!</h3> <p><i>N+1</i> ...
p02606
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>How many multiples of <var>d</var> are there among the integers between <var>L</var> and <var>R</var> (inclusive)?</p> </section> </div> <div class="part"> <section> <h3>Constraints</h3><ul> <li>All val...
p01303
<h1><font color="#000">Problem A:</font>ねこかわいがり</h1> <p> ある学園のキャンパス内には、多くのねこが住んでいる。なつめは、それらのねこをかわいがることを日課としている。 しかし、ねこ達は気まぐれで、キャンパスの外に散歩に出かけているかもしれない。 </p> <p> キャンパスの敷地は各辺が <var>x</var> 軸または <var>y</var> 軸に平行な長方形であり、門の部分を除いてフェンスで囲まれているが、ねこは門から自由に出入りできるし、また、フェンスを乗り越えて移動することもある。 </p> <p> ある日、なつめはキャンパス内にいるねこたちをなるべく平等に...
p01753
<p> 西暦20XX 年,学校対抗魔法競技大会が開かれていた.大会もいよいよ,最終競技を残すのみとなった.あなたはその競技の選手の1 人である. </p> <p> あなたが出場する競技は,空間内に配置された青いオブジェをすべて破壊するまでの時間を競うというものである.選手は競技用の銃の持込が許可されている.空間内には複数の青いオブジェと同じ数の赤いオブジェ,そして複数の障害物が配置されている.青いオブジェと赤いオブジェは1 対1 に対応しており,赤いオブジェが配置されている座標から青いオブジェに弾を撃つことで青いオブジェを破壊しなければならない.空間内に配置されている障害物は球状であり,少しずつ組成が異なっているが,通常の弾で...
p00841
<H1><font color="#000">Problem F:</font> Atomic Car Race</H1> <p> In the year 2020, a race of atomically energized cars will be held. Unlike today’s car races, fueling is not a concern of racing teams. Cars can run throughout the course without any refueling. Instead, the critical factor is tire (tyre). Teams should ...
p03294
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given <var>N</var> positive integers <var>a_1, a_2, ..., a_N</var>.</p> <p>For a non-negative integer <var>m</var>, let <var>f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N)</var>.</p>...
p00512
<H1>問題 3 </H1> <br/> <p>  ある工場では,各営業所から製品生産の注文を受けている. 前日の注文をまとめて,各製品の生産合計を求めたい. </p> <p>  入力ファイルの1行目には注文データの数 n が書いてあり, 続く n 行には製品名と注文数が空白で区切られて書いてある. 製品名は5文字以内の英大文字で書かれている. 注文データには同じ製品が含まれていることもあり,順序はバラバラである. </p> <p>  この注文データの中に現れる同じ製品の注文数を合計し, 出力ファイルに製品名と合計を空白を区切り文字として出力しなさい. ただし,製品名に次の順序を付けて,その順で出力すること. </p>...
p00142
<h1>素数の性質</h1> <p> 4 で割ると 3 あまる素数 <var>n</var> (11、19、23 など) には、面白い性質があります。1 以上 <var>n</var> 未満の自然数 (1, 2,... , <var>n</var> - 1) を 2 乗したものを <var>n</var> で割ったあまりを計算した結果を並べると、同じ数になるものがあるため、互いに異なった数の個数は、(<var>n</var> - 1)/2 になります。 </p> <p> この様にして得られた数の集合には、特別な性質があります。得られた数の集合から、互いに異なる 2 つ <var>a</var> と <var>b</var>...
p02190
<h2>Set</h2> <p>数列<var>a_1,a_2,..,a_N</var>が与えられます。</p> <p>この数列に値は何種類ありますか。</p> <h3>入力</h3> <pre> <var>N</var> <var>a_1 a_2...a_N</var> </pre> <h3>出力</h3> <p>数列の値の種類数を出力せよ。</p> <h3>制約</h3> <ul> <li><var>1 \leq N \leq 10^5 </var></li> <li><var>1 \leq a_i \leq 10^9</var></li> </ul> <h3>入力例</h3> <pre> 6 8 6 9 1 2 ...
p00457
<H1> 連鎖 </H1> <h2>問題</h2> <p> 次のようなゲームがある. </p> <p> あるキャラクターが縦 1 列に N 個並んでいる.これらのキャラクターの色は赤,青,黄のいずれかであり,初期状態で同じ色のキャラクターが4つ以上連続して並んでいることはない.プレーヤーは,ある位置のキャラクターを選び他の色に変更することができる.この操作により同じ色のキャラクターが4つ以上連続して並ぶとそれらのキャラクターは消滅する.キャラクターが消滅することにより新たに同じ色のキャラクターが4つ以上連続して並ぶとそれらのキャラクターも消滅し,同じ色のキャラクターが4つ以上連続して並んでいる箇所がなくなるまでこの連鎖は続く...
p00007
<H1>Debt Hell</H1> <p> Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week. </p> <p> Write a program which computes the amount of the debt in <var>n</var> wee...
p04044
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Iroha has a sequence of <var>N</var> strings <var>S_1, S_2, ..., S_N</var>. The length of each string is <var>L</var>.</p> <p>She will concatenate all of the strings in some order, to produce a long str...
p03781
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There is a kangaroo at coordinate <var>0</var> on an infinite number line that runs from left to right, at time <var>0</var>. During the period between time <var>i-1</var> and time <var>i</var>, the kan...
p02893
<span class="lang-en"> <p>Score : <var>800</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given are integers <var>N</var> and <var>X</var>. For each integer <var>k</var> between <var>0</var> and <var>X</var> (inclusive), find the answer to the following question, then compute the sum of all ...
p01246
<H1><font color="#000">Problem D:</font> Land Mark</H1> <p> <i>“Hey, what’s up? It’s already 30 minutes past eleven!”</i> </p> <p> <i>“I’m so sorry, but actually I got lost. I have no idea where I am now at all and I got tired wandering around. Please help!”</i> </p> <p> - Today you came to the metropolis to play wit...
p01616
<h1>D: Statement Coverage / 命令網羅</h1> <p>「うわっ!なんてひどいコードだ!」</p> <p>古いソースコードを開きながら先輩が叫んでいる. また面倒な仕事が押し付けられそうだ…….</p> <p>ソースコードにはめまいがしそうなほどたくさんの if 文が並んでいる.</p> <pre> if 条件文 1; 命令 1 if 条件文 2; 命令 2 if 条件文 3; 命令 3 ... </pre> <p>どうやら制御の構造はそれほど複雑ではないらしい.</p> <p>1 つの条件文には,変数と NOT 演算子 "~" ,そ...
p02939
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given is a string <var>S</var> consisting of lowercase English letters. Find the maximum positive integer <var>K</var> that satisfies the following condition:</p> <ul> <li>There exists a partition of <v...
p00904
<H1><font color="#000">Problem A: </font> Ginkgo Numbers</H1> <p> We will define Ginkgo numbers and multiplication on Ginkgo numbers. </p> <p> A <i>Ginkgo number</i> is a pair &lt;<i>m</i>, <i>n</i>&gt; where <i>m</i> and <i>n</i> are integers. For example, &lt;1, 1&gt;, &lt;-2, 1&gt; and &lt;-3,-1&gt; are Ginkgo nu...
p01179
<H1><font color="#000">Problem I:</font> Cousin's Aunt</H1> <p> Sarah is a girl who likes reading books. </p> <p> One day, she wondered about the relationship of a family in a mystery novel. The story said, </p> <ul> <li>B is A’s father’s brother’s son, and</li> <li>C is B’s aunt.</li> </ul> <p> Then she asked hers...
p03144
<span class="lang-en"> <p>Score : <var>1200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>N</var> jewels, numbered <var>1</var> to <var>N</var>. The color of these jewels are represented by integers between <var>1</var> and <var>K</var> (inclusive), and the color of Jewel <va...
p01483
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <body> <h1> Elevator</h1> <p> Time Limit: 8 sec / Memory Limit: 64 MB </p> <h2> E: エレベータ</h2> <p> あなたの友人は,キリンのマークの引越業者でアルバイトをしている. 彼の仕事は,建物から荷物を運び出すことである. </p> <p> 今回,彼はある<i>n</i>階建てのビルからいくつ...
p01529
<h1>J - 刺身</h1> <h2>問題文</h2> <p> きつねのしえるは川で釣りをしていた.黒くて細長い魚を手に入れることができたので,その場で切り刻んで刺身にして食べることにした. </p> <p> 魚は体長が <var>N</var> センチメートルある.奇妙なことに,この魚は身体の部分ごとに密度が異なっていた. 魚の身体を頭から 1 センチメートルごとに区切って番号を <var>1, 2, ..., N</var> と付けるとき,身体の <var>i</var> 番目の部分の重みは <var>w_i</var> であった. 魚の <var>i</var> 番目から <var>j</var> 番目までの部分を...
p03514
<span class="lang-en"> <p>Score : <var>100</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have <var>2N</var> pots. The market price of the <var>i</var>-th pot <var>(1 ≤ i ≤ 2N)</var> is <var>p_i</var> yen (the currency of Japan).</p> <p>Now, you and Lunlun the dachshund will alternately t...
p02755
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Find the price of a product before tax such that, when the consumption tax rate is <var>8</var> percent and <var>10</var> percent, the amount of consumption tax levied on it is <var>A</var> yen and <var...
p00768
<h3>ICPC Ranking</h3> <p> Your mission in this problem is to write a program which, given the submission log of an ICPC (International Collegiate Programming Contest), determines team rankings. </p> <p> The log is a sequence of records of program submission in the order of submission. A record has four fields: elaps...
p03847
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given a positive integer <var>N</var>. Find the number of the pairs of integers <var>u</var> and <var>v</var> <var>(0≦u,v≦N)</var> such that there exist two non-negative integers <var>a</var> an...
p00292
<h1>残り物には福がある</h2> <p> <var>K</var> 個の石から、<var>P</var> 人が順番に1つずつ石を取るゲームがあります。<var>P</var> 人目が石を取った時点で、まだ石が残っていれば、また1人目から順番に1つずつ石を取っていきます。このゲームでは、最後の石を取った人が勝ちとなります。<var>K</var> と<var>P</var> が与えられたとき、何人目が勝つか判定するプログラムを作成してください。 </p> <h2>入力</h2> <p> 入力は以下の形式で与えられる。 </p> <pre> <var>N</var> <var>K</var><sub>1</sub> <var...
p02305
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>Intersection of Circles</H1> <p> For given...
p00338
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>プログラミングコンテスト II</H1> <p> 白虎大学では毎年プログラミング...
p02610
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have <var>N</var> camels numbered <var>1,2,\ldots,N</var>. Snuke has decided to make them line up in a row.</p> <p>The happiness of Camel <var>i</var> will be <var>L_i</var> if it is among the <var>K...
p03902
<span class="lang-en"> <p>Score : <var>1200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Takahashi is a magician. He can cast a spell on an integer sequence <var>(a_1,a_2,...,a_M)</var> with <var>M</var> terms, to turn it into another sequence <var>(s_1,s_2,...,s_M)</var>, where <var>s_i</...
p00787
<H1><font color="#000">Problem H:</font> Digital Racing Circuit</H1> <p> You have an ideally small racing car on an <i>x-y</i> plane (0 &le; <i>x, y</i> &le; 255, where bigger <i>y</i> denotes upper coordinate). The racing circuit course is figured by two solid walls. Each wall is a closed loop of connected line segm...
p01895
<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>E: 札 / Fuda </h1> <p> この問題はリアクティブ問題です。 サーバー側に用意されたプログラムと対話的に...
p02240
<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>Connected Components</H1> ...
p03001
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There is a rectangle in a coordinate plane. The coordinates of the four vertices are <var>(0,0)</var>, <var>(W,0)</var>, <var>(W,H)</var>, and <var>(0,H)</var>. You are given a point <var>(x,y)</var> wh...
p01196
<H1><font color="#000"></font>The Phantom</H1> <!-- Problem D --> <p> Mr. Hoge is in trouble. He just bought a new mansion, but it’s haunted by a phantom. He asked a famous conjurer Dr. Huga to get rid of the phantom. Dr. Huga went to see the mansion, and found that the phantom is scared by its own mirror images. Dr. ...
p03451
<span class="lang-en"> <p>Score : <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>We have a <var>2 \times N</var> grid. We will denote the square at the <var>i</var>-th row and <var>j</var>-th column (<var>1 \leq i \leq 2</var>, <var>1 \leq j \leq N</var>) as <var>(i, j)</var>.</p> <...
p00154
<H1>カードの組み合わせ</H1> <p> 整数が書いてあるカードが何枚か入っている袋を使ってゲームをしましょう。各回のゲームで参加者はまず、好きな数 <var>n</var> を一つ宣言します。そして、袋の中から適当な枚数だけカードを一度に取り出して、それらのカードに書かれた数の総和が <var>n</var> に等しければ豪華賞品がもらえます。なお、それぞれのゲーム終了後カードは袋に戻されます。 </p> <p> 袋の中の <var>m</var> 種類のカードの情報および、<var>g</var> 回のゲームで参加者が宣言した数を入力とし、それぞれのゲームで豪華商品をもらえるカードの組み合わせが何通りあるかを出力す...
p02169
<h1>Problem H: Count Words</h1> <h2>Problem</h2> <p> $M$ 種類の文字がある。それらを使って長さ $N$ の文字列を作る。使われている文字の種類数が $K$ 以上であるような文字列は何通りあるか。$998244353$ で割ったあまりを求めよ。<br><br> ここで長さ $N$ の2つの文字列が異なるとは以下のように定義される。 <ul><li> 2つの文字列を $S = S_1S_2 \ldots S_N$, $T = T_1T_2 \ldots T_N$ とした場合に、$S_i \neq T_i$ となるような $i$ $(1 \leq i \le...
p00504
<H1> お土産購入計画 (Gifts)</H1> <br/> <h2>問題</h2> <p> オーストラリアに旅行に来た JOI 君は様々な場所で観光を楽しみ,ついに帰国する日がやってきた.今,JOI 君は帰りの飛行機が出発する国際空港のある町にいる.この町は東西南北に区画整理されており,各区画には道,土産店,住宅,国際空港がある. JOI 君は最も北西の区画から出発して最も南東の区画の国際空港を目指す. </p> <p> JOI 君は今いる区画から隣り合った区画に移動することができるが,住宅のある区画には入ることはできない.また飛行機の時間に間に合わせるために,今いる区画の東か南の区画にのみ移動する.ただし,時間にはい...
p02539
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>There are <var>2N</var> people numbered <var>1</var> through <var>2N</var>. The height of Person <var>i</var> is <var>h_i</var>.</p> <p>How many ways are there to make <var>N</var> pairs of people such ...
p03282
<span class="lang-en"> <p>Score: <var>300</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3> <p>Mr. Infinity has a string <var>S</var> consisting of digits from <code>1</code> to <code>9</code>. Each time the date changes, this string changes as follows:</p> <ul> <li>Each occurrence of <code>2</c...
p00857
<H1><font color="#000">Problem D:</font> Lowest Pyramid</H1> <p> You are constructing a triangular pyramid with a sheet of craft paper with grid lines. Its base and sides are all of triangular shape. You draw the base triangle and the three sides connected to the base on the paper, cut along the outer six edges, fold...
p03778
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>AtCoDeer the deer found two rectangles lying on the table, each with height <var>1</var> and width <var>W</var>. If we consider the surface of the desk as a two-dimensional plane, the first rectangle co...
p01745
<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> <p> <var>w</var> を正整数,<var>p</v...
p03328
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>In some village, there are <var>999</var> towers that are <var>1,(1+2),(1+2+3),...,(1+2+3+...+999)</var> meters high from west to east, at intervals of <var>1</var> meter.</p> <p>It had been snowing for...