Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
AtCoder 村には N 本の橋があり、i 本目( i は 1 以上 N 以下の整数)の橋の高さは H_i です。
ここで、AtCoder 村にある N 本の橋のうち、どの相異なる 2 本の橋も高さが異なります。
AtCoder 村で最も高い橋は何本目の橋か出力してください。
制約
- 1\leq N \leq 100
- 1\leq H_i \leq 10^9
- H_i はすべて異なる
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N H_1 H_2 \ldots H_N
出力
AtCoder 村で最も高い橋は何本目の橋かを、整数で出力せよ。
入力例 1
3 50 80 70
出力例 1
2
AtCoder 村には 3 本の橋があります。
1,2,3 本目の橋の高さはそれぞれ, 50,80,70 であり、
最も高い橋は 2 本目の橋です。
よって、2 を出力します。
入力例 2
1 1000000000
出力例 2
1
AtCoder 村に橋が 1 本しか存在しないため、2 本目以降の橋は存在せず、最も高い橋は 1 本目の橋となります。
入力例 3
10 22 75 26 45 72 81 47 29 97 2
出力例 3
9
AtCoder 村には 10 本の橋があり、それらのうち最も高い橋は 9 番目の橋(高さは 97 )です。
Score : 100 points
Problem Statement
There are N bridges in AtCoder Village. The height of the bridge numbered i is H_i (i is an integer between 1 and N).
Every two different bridges in the village have different heights.
Print the number representing the highest bridge in the village.
Constraints
- 1\leq N \leq 100
- 1\leq H_i \leq 10^9
- All H_i are different.
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
N H_1 H_2 \ldots H_N
Output
Print the integer representing the highest bridge in AtCoder village.
Sample Input 1
3 50 80 70
Sample Output 1
2
The village has three bridges.
The first, second, and third bridges have heights of 50, 80, and 70, respectively,
so the second bridge is the highest.
Thus, 2 should be printed.
Sample Input 2
1 1000000000
Sample Output 2
1
The village has only one bridge, so the first bridge is the highest.
Sample Input 3
10 22 75 26 45 72 81 47 29 97 2
Sample Output 3
9
The village has ten bridges, and the ninth bridge (with a height of 97) is the highest.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
非負整数 x に対し定義される関数 f(x) は以下の条件を満たします。
- f(0) = 1
- 任意の正整数 k に対し f(k) = k \times f(k-1)
このとき、 f(N) を求めてください。
制約
- N は 0 \le N \le 10 を満たす整数
入力
入力は以下の形式で標準入力から与えられる。
N
出力
答えを整数として出力せよ。
入力例 1
2
出力例 1
2
f(2) = 2 \times f(1) = 2 \times 1 \times f(0) = 2 \times 1 \times 1 = 2 です。
入力例 2
3
出力例 2
6
f(3) = 3 \times f(2) = 3 \times 2 = 6 です。
入力例 3
0
出力例 3
1
入力例 4
10
出力例 4
3628800
Score : 100 points
Problem Statement
A function f(x) defined for non-negative integer x satisfies the following conditions:
- f(0) = 1;
- f(k) = k \times f(k-1) for all positive integers k.
Find f(N).
Constraints
- N is an integer such that 0 \le N \le 10.
Input
The input is given from Standard Input in the following format:
N
Output
Print the answer as an integer.
Sample Input 1
2
Sample Output 1
2
We have f(2) = 2 \times f(1) = 2 \times 1 \times f(0) = 2 \times 1 \times 1 = 2.
Sample Input 2
3
Sample Output 2
6
We have f(3) = 3 \times f(2) = 3 \times 2 = 6.
Sample Input 3
0
Sample Output 3
1
Sample Input 4
10
Sample Output 4
3628800
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 250 点
問題文
H 行 W 列のグリッドがあり、はじめすべてのマスが白で塗られています。グリッドの上から i 行目、左から j 列目のマスを (i, j) と表記します。
このグリッドはトーラス状であるとみなします。すなわち、各 1 \leq i \leq H に対して (i, W) の右に (i, 1) があり、各 1 \leq j \leq W に対して (H, j) の下に (1, j) があるとします。
高橋君が (1, 1) にいて上を向いています。高橋君が以下の操作を N 回繰り返した後のグリッドの各マスがどの色で塗られているか出力してください。
- 現在いるマスが白で塗られている場合は、現在いるマスを黒に塗り替え、時計回りに 90^\circ 回転し、向いている方向に 1 マス進む。そうでない場合は、現在いるマスを白に塗り替え、反時計回りに 90^\circ 回転し、向いている方向に 1 マス進む。
制約
- 1 \leq H, W \leq 100
- 1 \leq N \leq 1000
- 入力される数値はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
H W N
出力
H 行出力せよ。i 行目には長さ W の文字列であって、(i, j) が白で塗られている場合は j 文字目が .、黒で塗られている場合は j 文字目が # であるものを出力せよ。
入力例 1
3 4 5
出力例 1
.#.. ##.. ....
グリッドの各マスは操作によって以下のように変化します。
.... #... ##.. ##.. ##.. .#.. .... → .... → .... → .#.. → ##.. → ##.. .... .... .... .... .... ....
入力例 2
2 2 1000
出力例 2
.. ..
入力例 3
10 10 10
出力例 3
##........ ##........ .......... .......... .......... .......... .......... .......... .......... #........#
Score: 250 points
Problem Statement
There is a grid with H rows and W columns; initially, all cells are painted white. Let (i, j) denote the cell at the i-th row from the top and the j-th column from the left.
This grid is considered to be toroidal. That is, (i, 1) is to the right of (i, W) for each 1 \leq i \leq H, and (1, j) is below (H, j) for each 1 \leq j \leq W.
Takahashi is at (1, 1) and facing upwards. Print the color of each cell in the grid after Takahashi repeats the following operation N times.
- If the current cell is painted white, repaint it black, rotate 90^\circ clockwise, and move forward one cell in the direction he is facing. Otherwise, repaint the current cell white, rotate 90^\circ counterclockwise, and move forward one cell in the direction he is facing.
Constraints
- 1 \leq H, W \leq 100
- 1 \leq N \leq 1000
- All input values are integers.
Input
The input is given from Standard Input in the following format:
H W N
Output
Print H lines. The i-th line should contain a string of length W where the j-th character is . if the cell (i, j) is painted white, and # if it is painted black.
Sample Input 1
3 4 5
Sample Output 1
.#.. ##.. ....
The cells of the grid change as follows due to the operations:
.... #... ##.. ##.. ##.. .#.. .... → .... → .... → .#.. → ##.. → ##.. .... .... .... .... .... ....
Sample Input 2
2 2 1000
Sample Output 2
.. ..
Sample Input 3
10 10 10
Sample Output 3
##........ ##........ .......... .......... .......... .......... .......... .......... .......... #........#
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
AtCoder 国の暦では、一年は 1,2,\dots,M 番目の月の M か月からなり、そのうち i 番目の月は 1,2,\dots,D_i 番目の日の D_i 日からなります。
さらに、 AtCoder 国の一年の日数は奇数、即ち D_1+D_2+\dots+D_M は奇数です。
一年の真ん中の日は何番目の月の何番目の日か求めてください。
言い換えると、 1 番目の月の 1 番目の日を 1 日目としたときの (D_1+D_2+\dots+D_M+1)/2 日目が何番目の月の何番目の日かを求めてください。
制約
- 入力は全て整数
- 1 \le M \le 100
- 1 \le D_i \le 100
- D_1 + D_2 + \dots + D_M は奇数
入力
入力は以下の形式で標準入力から与えられる。
M D_1 D_2 \dots D_M
出力
答えが a 番目の月の b 番目の日であるとき、以下の形式で出力せよ。
a b
入力例 1
12 31 28 31 30 31 30 31 31 30 31 30 31
出力例 1
7 2
この入力では、 1 年は 31+28+31+30+31+30+31+31+30+31+30+31=365 日からなります。
真ん中の日は (365+1)/2 = 183 日目であり、これを求めることを考えます。
- 1,2,3,4,5,6 番目の月に含まれる日数の合計は 181 日です。
- 7 番目の月の 1 番目の日は 182 日目です。
- 7 番目の月の 2 番目の日は 183 日目です。
以上から、答えが 7 番目の月の 2 番目の日であることが分かります。
入力例 2
1 1
出力例 2
1 1
入力例 3
6 3 1 4 1 5 9
出力例 3
5 3
Score : 200 points
Problem Statement
In the calendar of AtCoderLand, a year consists of M months: month 1, month 2, \dots, month M. The i-th month consists of D_i days: day 1, day 2, \dots, day D_i.
Furthermore, the number of days in a year is odd, that is, D_1+D_2+\dots+D_M is odd.
Find what day of what month is the middle day of the year.
In other words, let day 1 of month 1 be the first day, and find a and b such that the ((D_1+D_2+\dots+D_M+1)/2)-th day is day b of month a.
Constraints
- All input values are integers.
- 1 \le M \le 100
- 1 \le D_i \le 100
- D_1 + D_2 + \dots + D_M is odd.
Input
The input is given from Standard Input in the following format:
M D_1 D_2 \dots D_M
Output
Let the answer be day b of month a, and print it in the following format:
a b
Sample Input 1
12 31 28 31 30 31 30 31 31 30 31 30 31
Sample Output 1
7 2
In this input, a year consists of 31+28+31+30+31+30+31+31+30+31+30+31=365 days.
Let us find the middle day, which is the ((365+1)/2 = 183)-th day.
- Months 1,2,3,4,5,6 contain a total of 181 days.
- Day 1 of month 7 is the 182-th day.
- Day 2 of month 7 is the 183-th day.
Thus, the answer is day 2 of month 7.
Sample Input 2
1 1
Sample Output 2
1 1
Sample Input 3
6 3 1 4 1 5 9
Sample Output 3
5 3
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 300 点
問題文
英小文字、,、" からなる長さ N の文字列 S が与えられます。S に含まれる " の個数は偶数であることが保証されています。
S に含まれる " の個数を 2K 個とすると、各 i=1,2,\ldots,K について 2i-1 番目の " から 2i 番目の " までの文字のことを 括られた文字 と呼びます。
あなたの仕事は、 S に含まれる , のうち、括られた文字 でないもの を . で置き換えて得られる文字列を答えることです。
制約
- N は 1 以上 2\times 10^5 以下の整数
- S は英小文字、
,、"からなる長さ N の文字列 - S に含まれる
"の個数は偶数
入力
入力は以下の形式で標準入力から与えられる。
N S
出力
答えを出力せよ。
入力例 1
8 "a,b"c,d
出力例 1
"a,b"c.d
S のうち "a,b" が括られた文字であり、c,d は括られた文字ではありません。
S に含まれる , のうち、括られた文字でないのは S の左から 7 番目の文字なので、7 番目の文字を . で置き換えたものが答えとなります。
入力例 2
5 ,,,,,
出力例 2
.....
入力例 3
20 a,"t,"c,"o,"d,"e,"r,
出力例 3
a."t,"c."o,"d."e,"r.
Score : 300 points
Problem Statement
You are given a string S of length N consisting of lowercase English letters, ,, and ". It is guaranteed that S contains an even number of ".
Let 2K be the number of " in S. For each i=1,2,\ldots,K, the characters from the (2i-1)-th " through the (2i)-th " are said to be enclosed.
Your task is to replace each , in S that is not an enclosed character with . and print the resulting string.
Constraints
- N is an integer between 1 and 2\times 10^5, inclusive.
- S is a string of length N consisting of lowercase English letters,
,, and". - S contains an even number of
".
Input
The input is given from Standard Input in the following format:
N S
Output
Print the answer.
Sample Input 1
8 "a,b"c,d
Sample Output 1
"a,b"c.d
In S, "a,b" are enclosed characters, and c,d are not.
The , in S that is not an enclosed character is the seventh character from the left in S, so replace that character with . to get the answer.
Sample Input 2
5 ,,,,,
Sample Output 2
.....
Sample Input 3
20 a,"t,"c,"o,"d,"e,"r,
Sample Output 3
a."t,"c."o,"d."e,"r.