実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 100 点
問題文
髙橋君はサッカーの試合で N 回ペナルティキックを蹴ります。
髙橋君は i 回目のペナルティキックでは、i が 3 の倍数の場合は失敗しそれ以外の場合は成功します。
髙橋君がペナルティキックを蹴ったときの結果を出力してください。
制約
- 1 \leq N \leq 100
- 入力は全て整数である。
入力
入力は以下の形式で標準入力から与えられる。
N
出力
髙橋君のペナルティキックの結果を表す長さ N の文字列を出力せよ。結果を表す文字列の i (1 \leq i \leq N) 文字目は髙橋君が i 回目のペナルティキックで成功した場合は o 、失敗した場合は x とする。
入力例 1
7
出力例 1
ooxooxo
髙橋君は 3 回目と 6 回目のペナルティキックに失敗するので、3 文字目と 6 文字目が x となります。
入力例 2
9
出力例 2
ooxooxoox
Score: 100 points
Problem Statement
Takahashi will have N penalty kicks in a soccer match.
For the i-th penalty kick, he will fail if i is a multiple of 3, and succeed otherwise.
Print the results of his penalty kicks.
Constraints
- 1 \leq N \leq 100
- All inputs are integers.
Input
The input is given from Standard Input in the following format:
N
Output
Print a string of length N representing the results of Takahashi's penalty kicks. The i-th character (1 \leq i \leq N) should be o if Takahashi succeeds in the i-th penalty kick, and x if he fails.
Sample Input 1
7
Sample Output 1
ooxooxo
Takahashi fails the third and sixth penalty kicks, so the third and sixth characters will be x.
Sample Input 2
9
Sample Output 2
ooxooxoox
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 100 点
問題文
正の整数 N が与えられます。
N,N-1,\dots,1 をこの順にカンマ , で区切って出力してください。
制約
- 1\leq N \leq 9
- N は整数
入力
入力は以下の形式で標準入力から与えられる。
N
出力
N,N-1,\dots,1 をこの順にカンマ区切りで出力せよ。
入力例 1
9
出力例 1
9,8,7,6,5,4,3,2,1
入力例 2
5
出力例 2
5,4,3,2,1
入力例 3
1
出力例 3
1
Score : 100 points
Problem Statement
You are given a positive integer N.
Output N, N-1, \dots, 1 in this order, separated by commas ,.
Constraints
- 1 \leq N \leq 9
- N is an integer.
Input
The input is given from Standard Input in the following format:
N
Output
Output N, N-1, \dots, 1 in this order, separated by commas.
Sample Input 1
9
Sample Output 1
9,8,7,6,5,4,3,2,1
Sample Input 2
5
Sample Output 2
5,4,3,2,1
Sample Input 3
1
Sample Output 3
1
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 150 点
問題文
2 次元座標平面の原点に高橋くんがいます。
高橋くんが座標平面上の点 (a,b) から点 (c,d) に移動するには \sqrt{(a-c)^2+(b-d)^2} のコストがかかります。
高橋くんが原点からスタートし N 個の点 (X_1,Y_1),\ldots,(X_N,Y_N) へこの順に移動したのち原点に戻るときの、コストの総和を求めてください。
制約
- 1 \leq N \leq 2\times 10^5
- -10^9 \leq X_i,Y_i \leq 10^9
- 入力は全て整数である
入力
入力は以下の形式で標準入力から与えられる。
N X_1 Y_1 \vdots X_N Y_N
出力
答えを出力せよ。
真の値との相対誤差または絶対誤差が 10^{-6} 以下であれば正解とみなされる。
入力例 1
2 1 2 -1 0
出力例 1
6.06449510224597979401
移動は次の 3 行程からなります。
- (0,0) から (1,2) に移動する。\sqrt{(0-1)^2+(0-2)^2}=\sqrt{5}=2.236067977... のコストがかかる
- (1,2) から (-1,0) に移動する。\sqrt{(1-(-1))^2+(2-0)^2}=\sqrt{8}=2.828427124... のコストがかかる
- (-1,0) から (0,0) に移動する。\sqrt{(-1-0)^2+(0-0)^2}=\sqrt{1}=1 のコストがかかる
コストの総和は 6.064495102... となります。
入力例 2
7 -14142 13562 -17320 50807 -22360 67977 24494 89742 -26457 51311 28284 27124 31622 77660
出力例 2
384694.57587932075868509383
入力例 3
5 -100000 100000 100000 -100000 -100000 100000 100000 -100000 -100000 100000
出力例 3
1414213.56237309504880168872
Score : 150 points
Problem Statement
Takahashi is at the origin on a two-dimensional coordinate plane.
The cost for him to move from point (a, b) to point (c, d) is \sqrt{(a - c)^2 + (b - d)^2}.
Find the total cost when he starts at the origin, visits N points (X_1, Y_1), \ldots, (X_N, Y_N) in this order, and then returns to the origin.
Constraints
- 1 \leq N \leq 2 \times 10^5
- -10^9 \leq X_i, Y_i \leq 10^9
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N X_1 Y_1 \vdots X_N Y_N
Output
Print the answer.
Your output will be considered correct if its absolute or relative error from the true value is at most 10^{-6}.
Sample Input 1
2 1 2 -1 0
Sample Output 1
6.06449510224597979401
The journey consists of the following three steps:
- Move from (0, 0) to (1, 2). The cost is \sqrt{(0 - 1)^2 + (0 - 2)^2} = \sqrt{5} = 2.236067977....
- Move from (1, 2) to (-1, 0). The cost is \sqrt{(1 - (-1))^2 + (2 - 0)^2} = \sqrt{8} = 2.828427124....
- Move from (-1, 0) to (0, 0). The cost is \sqrt{(-1 - 0)^2 + (0 - 0)^2} = \sqrt{1} = 1.
The total cost is 6.064495102....
Sample Input 2
7 -14142 13562 -17320 50807 -22360 67977 24494 89742 -26457 51311 28284 27124 31622 77660
Sample Output 2
384694.57587932075868509383
Sample Input 3
5 -100000 100000 100000 -100000 -100000 100000 100000 -100000 -100000 100000
Sample Output 3
1414213.56237309504880168872
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 200 点
問題文
チェス盤のどこにコマが置かれているか答えてください。
縦 8 マス、横 8 マスのグリッドがあります。グリッドの各マスには、次のルールで定められる長さ 2 の文字列の名前がついています。
- 左から 1 列目にあるマスの名前の 1 文字目は
aである。同様に、左から 2,3,\ldots,8 列目にあるマスの名前の 1 文字目はb,c,d,e,f,g,hである。 - 下から 1 行目にあるマスの名前の 2 文字目は
1である。同様に、下から 2,3,\ldots,8 行目にあるマスの名前の 2 文字目は2,3,4,5,6,7,8である。
例えば、グリッドの左下のマスの名前は a1、右下のマスの名前は h1、右上のマスの名前は h8 です。
グリッドの状態を表す長さ 8 の 8 つの文字列 S_1,\ldots,S_8 が与えられます。
S_i の j 文字目は、グリッドの上から i 行目 左から j 列目のマスにコマが置かれているとき *、置かれていないとき . であり、S_1,\ldots,S_8 の中に文字 * はちょうど 1 つ存在します。
コマが置かれているマスの名前を求めてください。
制約
- S_i は
.および*のみからなる長さ 8 の文字列である - S_1,\ldots,S_8 の中に文字
*はちょうど 1 つ存在する。
入力
入力は以下の形式で標準入力から与えられる。
S_1 S_2 S_3 S_4 S_5 S_6 S_7 S_8
出力
答えを出力せよ。
入力例 1
........ ........ ........ ........ ........ ........ ........ *.......
出力例 1
a1
問題文中で説明したとおり、グリッドの左下のマスの名前は a1 です。
入力例 2
........ ........ ........ ........ ........ .*...... ........ ........
出力例 2
b3
Score : 200 points
Problem Statement
Locate a piece on a chessboard.
We have a grid with 8 rows and 8 columns of squares. Each of the squares has a 2-character name determined as follows.
- The first character of the name of a square in the 1-st column from the left is
a. Similarly, the first character of the name of a square in the 2-nd, 3-rd, \ldots, 8-th column from the left isb,c,d,e,f,g,h, respectively. - The second character of the name of a square in the 1-st row from the bottom is
1. Similarly, the second character of the name of a square in the 2-nd, 3-rd, \ldots, 8-th row from the bottom is2,3,4,5,6,7,8, respectively.
For instance, the bottom-left square is named a1, the bottom-right square is named h1, and the top-right square is named h8.
You are given 8 strings S_1,\ldots,S_8, each of length 8, representing the state of the grid.
The j-th character of S_i is * if the square at the i-th row from the top and j-th column from the left has a piece on it, and . otherwise.
The character * occurs exactly once among S_1,\ldots,S_8.
Find the name of the square that has a piece on it.
Constraints
- S_i is a string of length 8 consisting of
.and*. - The character
*occurs exactly once among S_1,\ldots,S_8.
Input
The input is given from Standard Input in the following format:
S_1 S_2 S_3 S_4 S_5 S_6 S_7 S_8
Output
Print the answer.
Sample Input 1
........ ........ ........ ........ ........ ........ ........ *.......
Sample Output 1
a1
As explained in the problem statement, the bottom-left square is named a1.
Sample Input 2
........ ........ ........ ........ ........ .*...... ........ ........
Sample Output 2
b3
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 300 点
問題文
N 個のリールからなるスロットがあります。
i 番目のリールの配列は文字列 S_i によって表されます。
ここで、S_i は 0, 1, \ldots, 9 がちょうど 1 回ずつ現れる長さ 10 の文字列です。
それぞれのリールには対応するボタンがついており、高橋君は各非負整数 t について、
スロットが回り始めてからちょうど t 秒後にボタンを 1 つ選んで押す(または何もしない)ことができます。
スロットが回り始めてから t 秒後に i 番目のリールに対応するボタンを押すと、
i 番目のリールは S_i の (t\bmod{10})+1 文字目を表示して止まります。
ただし、t\bmod{10} で t を 10 で割ったあまりを表します。
高橋君は全てのリールを止めた上で、表示されている文字が全て同じであるようにしたいです。
高橋君が目標を達成できるように全てのリールを止めるまでに、スロットが回り始めてから最小で何秒かかるかを求めてください。
制約
- 2\leq N\leq 100
- N は整数
- S_i は
0,1, \ldots,9がちょうど 1 回ずつ現れる長さ 10 の文字列
入力
入力は以下の形式で標準入力から与えられる。
N S_1 S_2 \vdots S_N
出力
高橋君が目標を達成できるように全てのリールを止めるまでに、スロットが回り始めてから最小で何秒かかるかを出力せよ。
入力例 1
3 1937458062 8124690357 2385760149
出力例 1
6
高橋君は次のようにそれぞれのリールを止めることでスロットが回り始めてから 6 秒後にリールに表示される文字を 8 で揃えることができます。
- スロットの回転開始から 0 秒後に 2 番目のリールに対応するボタンを押します。2 番目のリールは S_2 の (0\bmod{10})+1=1 文字目である
8を表示して止まります。 - スロットの回転開始から 2 秒後に 3 番目のリールに対応するボタンを押します。3 番目のリールは S_3 の (2\bmod{10})+1=3 文字目である
8を表示して止まります。 - スロットの回転開始から 6 秒後に 1 番目のリールに対応するボタンを押します。1 番目のリールは S_1 の (6\bmod{10})+1=7 文字目である
8を表示して止まります。
5 秒以下で全てのリールに表示されている文字を揃える方法はないため、6 を出力します。
入力例 2
5 0123456789 0123456789 0123456789 0123456789 0123456789
出力例 2
40
全てのリールを止めた上で、表示されている文字を揃える必要がある事に注意してください。
Score : 300 points
Problem Statement
There is a slot machine with N reels.
The placement of symbols on the i-th reel is represented by a string S_i of length 10 containing each of 0, 1, \ldots, 9 exactly once.
Each reel has a corresponding button. For each non-negative integer t, Takahashi can press one of the buttons of his choice (or do nothing) t seconds after the reels start spinning.
If the button for the i-th reel is pressed t seconds after the start of the spin, the i-th reel will stop to display the ((t\bmod{10})+1)-th character of S_i.
Here, t\bmod{10} denotes the remainder when t is divided by 10.
Takahashi wants to stop all reels to make them display the same character.
Find the minimum number of seconds needed to achieve his objective after the start of the spin.
Constraints
- 2\leq N\leq 100
- N is an integer.
- S_i is a string of length 10 containing each of
0,1, \ldots,9exactly once.
Input
Input is given from Standard Input in the following format:
N S_1 S_2 \vdots S_N
Output
Print the minimum number of seconds needed to achieve Takahashi's objective after the start of the spin.
Sample Input 1
3 1937458062 8124690357 2385760149
Sample Output 1
6
Takahashi can make all reels display 8 in 6 seconds after the start of the spin by stopping them as follows.
- 0 seconds after the start of the spin, press the button for the 2-nd reel, making it stop to display the ((0\bmod{10})+1=1)-st character of S_2,
8. - 2 seconds after the start of the spin, press the button for the 3-rd reel, making it stop to display the ((2\bmod{10})+1=3)-rd character of S_3,
8. - 6 seconds after the start of the spin, press the button for the 1-st reel, making it stop to display the ((6\bmod{10})+1=7)-th character of S_1,
8.
There is no way to make all reels display the same character in five seconds or less, so the answer is 6.
Sample Input 2
5 0123456789 0123456789 0123456789 0123456789 0123456789
Sample Output 2
40
Note that he must stop all reels to make them display the same character.