Time Limit: 2 sec / Memory Limit: 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
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
高橋君は N 歳の誕生日を迎えました。この時の彼の身長は T cmです。
また、以下のことが分かっています。
- 高橋君は 0 歳の誕生日(生まれた当日)から X 歳の誕生日までの間、毎年身長が D cmずつ伸びた。より厳密に書くと、i=1,2,\ldots,X それぞれに対し、i-1 歳の誕生日から i 歳の誕生日までの間に身長が D cm伸びた。
- 高橋君は X 歳の誕生日から N 歳の誕生日までの間、身長が変化していない。
高橋君の M 歳の誕生日の時の身長が何cmだったかを求めてください。
制約
- 0 \leq M \lt N \leq 100
- 1 \leq X \leq N
- 1 \leq T \leq 200
- 1 \leq D \leq 100
- 高橋君の 0 歳の誕生日の時の身長は 1 cm以上である
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N M X T D
出力
答えを整数として出力せよ。
入力例 1
38 20 17 168 3
出力例 1
168
この例では、高橋君の 38 歳の誕生日の時の身長が 168 cmです。また、17 歳の誕生日から 38 歳の誕生日までの間、身長が変化していません。
このことから、20 歳の誕生日の時の身長は 168 cmだったと言え、これが答えになります。
入力例 2
1 0 1 3 2
出力例 2
1
この例において、高橋君は 0(=M) 歳の誕生日の時の身長が 1 cmで、1(=N) 歳の誕生日の時の身長が 3(=T) cmです。
入力例 3
100 10 100 180 1
出力例 3
90
Score : 100 points
Problem Statement
Takahashi had his N-th birthday, when he was T centimeters tall.
Additionally, we know the following facts:
- In each year between Takahashi's birth (0-th birthday) and his X-th birthday, his height increased by D centimeters. More formally, for each i = 1, 2, \ldots, X, his height increased by D centimeters between his (i-1)-th birthday and his i-th birthday.
- Between Takahashi's X-th birthday and his N-th birthday, his height did not change.
Find Takahashi's height on his M-th birthday, in centimeters.
Constraints
- 0 \leq M \lt N \leq 100
- 1 \leq X \leq N
- 1 \leq T \leq 200
- 1 \leq D \leq 100
- Takahashi was at least 1 centimeter tall at his birth.
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
N M X T D
Output
Print the answer as an integer.
Sample Input 1
38 20 17 168 3
Sample Output 1
168
In this sample, Takahashi was 168 centimeters tall on his 38-th birthday. Also, his height did not change between his 17-th birthday and 38-th birthday.
From these facts, we find that he was 168 centimeters tall on his 20-th birthday, so the answer is 168.
Sample Input 2
1 0 1 3 2
Sample Output 2
1
In this sample, Takahashi was 1 centimeter tall on his 0(=M)-th birthday and 3(=T) centimeters tall on his 1(=N)-st birthday.
Sample Input 3
100 10 100 180 1
Sample Output 3
90
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
英大文字と数字からなる文字列 S が与えられるので、S が以下の条件を満たすか判定してください。
- S は次の文字または文字列をこの順番で連結して得られる。
- 一文字の英大文字
- 100000 以上 999999 以下の整数を 10 進表記して得られる長さ 6 の文字列
- 一文字の英大文字
制約
- S は英大文字と数字からなる
- S の長さは 1 以上 10 以下
入力
入力は以下の形式で標準入力から与えられる。
S
出力
S が問題文中の条件を満たすなら Yes と、満たさないなら No と出力せよ。
入力例 1
Q142857Z
出力例 1
Yes
S は Q、142857、Z をこの順に連結して得られます。
Q、Z は英大文字であり、142857 は 100000 以上 999999 以下の整数を 10 進表記して得られる長さ 6 の文字列なので、S は条件を満たします。
入力例 2
AB912278C
出力例 2
No
AB は一文字の英大文字ではないため、S は条件を満たしません。
入力例 3
X900000
出力例 3
No
S の末尾の一文字が英大文字ではないため、S は条件を満たしません。
入力例 4
K012345K
出力例 4
No
012345 は 100000 以上 999999 以下の整数を 10 進表記して得られる長さ 6 の文字列ではないため、S は条件を満たしません。
Score : 200 points
Problem Statement
You are given a string S consisting of uppercase English letters and digits. Determine whether S satisfies the following condition.
- S is a concatenation of the following characters and string in the order listed.
- An uppercase English letter
- A string of length 6 that is a decimal representation of an integer between 100000 and 999999, inclusive
- An uppercase English letter
Constraints
- S consists of uppercase English letters and digits.
- The length of S is between 1 and 10, inclusive.
Input
The input is given from Standard Input in the following format:
S
Output
If S satisfies the condition in the problem statement, print Yes; otherwise, print No.
Sample Input 1
Q142857Z
Sample Output 1
Yes
S is a concatenation of Q, 142857, and Z in this order.
Q and Z are uppercase English letters, and 142857 is a string of length 6 that is a decimal representation of an integer between 100000 and 999999, so S satisfies the condition.
Sample Input 2
AB912278C
Sample Output 2
No
AB is not an uppercase English letter, so S does not satisfy the condition.
Sample Input 3
X900000
Sample Output 3
No
The last character of S is not an uppercase English letter, so S does not satisfy the condition.
Sample Input 4
K012345K
Sample Output 4
No
012345 is not a string of length 6 that is a decimal representation of an integer between 100000 and 999999, so S does not satisfy the condition.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
N 頂点 M 辺の単純無向グラフが与えられます。頂点には 1, \dots, N の番号が付けられており、i \, (1 \leq i \leq M) 番目の辺は頂点 U_i と頂点 V_i を結んでいます。
以下の条件を全て満たす整数 a, b, c の組の総数を求めてください。
- 1 \leq a \lt b \lt c \leq N
- 頂点 a と頂点 b を結ぶ辺が存在する。
- 頂点 b と頂点 c を結ぶ辺が存在する。
- 頂点 c と頂点 a を結ぶ辺が存在する。
制約
- 3 \leq N \leq 100
- 1 \leq M \leq \frac{N(N - 1)}{2}
- 1 \leq U_i \lt V_i \leq N \, (1 \leq i \leq M)
- (U_i, V_i) \neq (U_j, V_j) \, (i \neq j)
- 入力は全て整数
入力
入力は以下の形式で標準入力から与えられる。
N M U_1 V_1 \vdots U_M V_M
出力
答えを出力せよ。
入力例 1
5 6 1 5 4 5 2 3 1 4 3 5 2 5
出力例 1
2
(a, b, c) = (1, 4, 5), (2, 3, 5) が条件を満たします。
入力例 2
3 1 1 2
出力例 2
0
入力例 3
7 10 1 7 5 7 2 5 3 6 4 7 1 5 2 4 1 3 1 6 2 7
出力例 3
4
Score : 200 points
Problem Statement
You are given a simple undirected graph with N vertices and M edges. The vertices are numbered 1, \dots, N, and the i-th (1 \leq i \leq M) edge connects Vertex U_i and Vertex V_i.
Find the number of tuples of integers a, b, c that satisfy all of the following conditions:
- 1 \leq a \lt b \lt c \leq N
- There is an edge connecting Vertex a and Vertex b.
- There is an edge connecting Vertex b and Vertex c.
- There is an edge connecting Vertex c and Vertex a.
Constraints
- 3 \leq N \leq 100
- 1 \leq M \leq \frac{N(N - 1)}{2}
- 1 \leq U_i \lt V_i \leq N \, (1 \leq i \leq M)
- (U_i, V_i) \neq (U_j, V_j) \, (i \neq j)
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
N M U_1 V_1 \vdots U_M V_M
Output
Print the answer.
Sample Input 1
5 6 1 5 4 5 2 3 1 4 3 5 2 5
Sample Output 1
2
(a, b, c) = (1, 4, 5), (2, 3, 5) satisfy the conditions.
Sample Input 2
3 1 1 2
Sample Output 2
0
Sample Input 3
7 10 1 7 5 7 2 5 3 6 4 7 1 5 2 4 1 3 1 6 2 7
Sample Output 3
4
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 300 点
問題文
高橋君はレベル N の赤い宝石を 1 個持っています。(他に宝石は持っていません。)
高橋君は次の操作を好きなだけ行うことができます。
- レベル n の赤い宝石 (n は 2 以上) を「レベル n-1 の赤い宝石 1 個と、レベル n の青い宝石 X 個」に変換する。
- レベル n の青い宝石 (n は 2 以上) を「レベル n-1 の赤い宝石 1 個と、レベル n-1 の青い宝石 Y 個」に変換する。
高橋君はレベル 1 の青い宝石ができるだけたくさんほしいです。操作によって高橋君はレベル 1 の青い宝石を最大何個入手できますか?
制約
- 1 \leq N \leq 10
- 1 \leq X \leq 5
- 1 \leq Y \leq 5
- 入力される値はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N X Y
出力
答えを出力せよ。
入力例 1
2 3 4
出力例 1
12
次のような変換を行うことで、高橋君はレベル 1 の青い宝石を 12 個手に入れることができます。
- まず、レベル 2 の赤い宝石 1 個を、レベル 1 の赤い宝石 1 個とレベル 2 の青い宝石 3 個に変換します。
- 操作後の高橋君は、レベル 1 の赤い宝石 1 個とレベル 2 の青い宝石 3 個を持っています。
- 次に、レベル 2 の青い宝石 1 個を、レベル 1 の赤い宝石 1 個とレベル 1 の青い宝石 4 個に変換します。この変換を 3 回繰り返します。
- 操作後の高橋君は、レベル 1 の赤い宝石 4 個とレベル 1 の青い宝石 12 個を持っています。
- これ以上変換を行うことはできません。
12 個より多くレベル 1 の青い宝石を手に入れることはできないので、答えは 12 になります。
入力例 2
1 5 5
出力例 2
0
高橋君がレベル 1 の青い宝石を 1 個も手に入れられない場合もあります。
入力例 3
10 5 5
出力例 3
3942349900
答えが 32 bit 整数に収まらない場合があることに注意してください。
Score : 300 points
Problem Statement
Takahashi has a red jewel of level N. (He has no other jewels.)
Takahashi can do the following operations any number of times.
- Convert a red jewel of level n (n is at least 2) into "a red jewel of level (n-1) and X blue jewels of level n".
- Convert a blue jewel of level n (n is at least 2) into "a red jewel of level (n-1) and Y blue jewels of level (n-1)".
Takahashi wants as many blue jewels of level 1 as possible. At most, how many blue jewels of level 1 can he obtain by the operations?
Constraints
- 1 \leq N \leq 10
- 1 \leq X \leq 5
- 1 \leq Y \leq 5
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
N X Y
Output
Print the answer.
Sample Input 1
2 3 4
Sample Output 1
12
Takahashi can obtain 12 blue jewels of level 1 by the following conversions.
- First, he converts a red jewel of level 2 into a red jewel of level 1 and 3 blue jewels of level 2.
- After this operation, Takahashi has 1 red jewel of level 1 and 3 blue jewels of level 2.
- Next, he repeats the following conversion 3 times: converting a blue jewel of level 2 into a red jewel of level 1 and 4 blue jewels of level 1.
- After these operations, Takahashi has 4 red jewels of level 1 and 12 blue jewels of level 1.
- He cannot perform a conversion anymore.
He cannot obtain more than 12 blue jewels of level 1, so the answer is 12.
Sample Input 2
1 5 5
Sample Output 2
0
Takahashi may not be able to obtain a blue jewel of level 1.
Sample Input 3
10 5 5
Sample Output 3
3942349900
Note that the answer may not fit into a 32-bit integer type.