Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
100 以上 999 以下の整数 S が与えられます。
S が 200 以上 299 以下のとき Success
、そうでないとき Failure
と出力してください。
制約
- 100\leq S\leq999
- S は整数
入力
入力は以下の形式で標準入力から与えられる。
S
出力
答えを出力せよ。
入力例 1
200
出力例 1
Success
200 は 200 以上 299 以下なので、Success
と出力してください。
入力例 2
401
出力例 2
Failure
401 は 200 以上 299 以下ではないので、Failure
と出力してください。
入力例 3
999
出力例 3
Failure
Score : 100 points
Problem Statement
You are given an integer S between 100 and 999 (inclusive).
If S is between 200 and 299 (inclusive), print Success
; otherwise, print Failure
.
Constraints
- 100 \le S \le 999
- S is an integer.
Input
The input is given from Standard Input in the following format:
S
Output
Print the answer.
Sample Input 1
200
Sample Output 1
Success
200 is between 200 and 299, so print Success
.
Sample Input 2
401
Sample Output 2
Failure
401 is not between 200 and 299, so print Failure
.
Sample Input 3
999
Sample Output 3
Failure
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
配点 : 150 点
問題文
2N 人の人が横一列に並んでおり、左から i 番目の人は色 A_i の服を着ています。ここで、服の色は 1 から N の N 色であり、それぞれの色についてちょうど 2 人の人がその色の服を着ています。
i=1,2,\ldots,N のうち、以下の条件を満たすものは何通りあるか求めてください。
- 色 i の服を着た二人の人の間にはちょうど一人いる。
制約
- 2\leq N\leq 100
- 1\leq A_i \leq N
- A には 1 以上 N 以下の整数全てがそれぞれ 2 個ずつ含まれる
- 入力される数値は全て整数
入力
入力は以下の形式で標準入力から与えられる。
N A_1 A_2 \ldots A_{2N}
出力
答えを出力せよ。
入力例 1
3 1 2 1 3 2 3
出力例 1
2
条件を満たす i は 1 と 3 の 2 個です。
実際、色 1 の服を着ているのは左から 1 番目の人と左から 3 番目の人で、間にちょうど一人います。
入力例 2
2 1 1 2 2
出力例 2
0
条件を満たす i が存在しない場合もあります。
入力例 3
4 4 3 2 3 2 1 4 1
出力例 3
3
Score : 150 points
Problem Statement
There are 2N people standing in a row, and the person at the i-th position from the left is wearing clothes of color A_i. Here, the clothes have N colors from 1 to N, and exactly two people are wearing clothes of each color.
Find how many of the integers i=1,2,\ldots,N satisfy the following condition:
- There is exactly one person between the two people wearing clothes of color i.
Constraints
- 2 \leq N \leq 100
- 1 \leq A_i \leq N
- Each integer from 1 through N appears exactly twice in A.
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N A_1 A_2 \ldots A_{2N}
Output
Print the answer.
Sample Input 1
3 1 2 1 3 2 3
Sample Output 1
2
There are two values of i that satisfy the condition: 1 and 3.
In fact, the people wearing clothes of color 1 are at the 1st and 3rd positions from the left, with exactly one person in between.
Sample Input 2
2 1 1 2 2
Sample Output 2
0
There may be no i that satisfies the condition.
Sample Input 3
4 4 3 2 3 2 1 4 1
Sample Output 3
3
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
0 と 1 からなる長さ 64 の数列 A=(A_0,A_1,\dots,A_{63}) が与えられます。
A_0 2^0 + A_1 2^1 + \dots + A_{63} 2^{63} を求めてください。
制約
- A_i は 0 または 1
入力
入力は以下の形式で標準入力から与えられる。
A_0 A_1 \dots A_{63}
出力
答えを整数として出力せよ。
入力例 1
1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
出力例 1
13
A_0 2^0 + A_1 2^1 + \dots + A_{63} 2^{63} = 2^0 + 2^2 + 2^3 = 13 です。
入力例 2
1 0 1 0 1 0 0 0 0 1 0 0 1 1 0 1 1 1 1 0 0 0 1 0 0 1 1 1 1 1 1 0 0 0 0 1 0 1 0 1 0 1 1 1 1 0 0 1 1 0 0 0 0 1 0 1 0 1 0 1 0 0 0 0
出力例 2
766067858140017173
Score : 200 points
Problem Statement
You are given a sequence A=(A_0,A_1,\dots,A_{63}) of length 64 consisting of 0 and 1.
Find A_0 2^0 + A_1 2^1 + \dots + A_{63} 2^{63}.
Constraints
- A_i is 0 or 1.
Input
The input is given from Standard Input in the following format:
A_0 A_1 \dots A_{63}
Output
Print the answer as an integer.
Sample Input 1
1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Sample Output 1
13
A_0 2^0 + A_1 2^1 + \dots + A_{63} 2^{63} = 2^0 + 2^2 + 2^3 = 13.
Sample Input 2
1 0 1 0 1 0 0 0 0 1 0 0 1 1 0 1 1 1 1 0 0 0 1 0 0 1 1 1 1 1 1 0 0 0 0 1 0 1 0 1 0 1 1 1 1 0 0 1 1 0 0 0 0 1 0 1 0 1 0 1 0 0 0 0
Sample Output 2
766067858140017173
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 250 点
問題文
3 個の数列 A=(A_1,\ldots,A_N), B=(B_1,\ldots,B_M), C=(C_1,\ldots,C_L) が与えられます。
さらに数列 X=(X_1,\ldots,X_Q) が与えられるので、各 i=1,\ldots,Q に対して次の問題を解いてください。
問題:A,B,C からそれぞれ 1 個ずつ要素を選び、和を X_i にすることができるか?
制約
- 1 \leq N,M,L \leq 100
- 0 \leq A_i, B_i ,C_i \leq 10^8
- 1 \leq Q \leq 2\times 10^5
- 0 \leq X_i \leq 3\times 10^8
- 入力は全て整数である
入力
入力は以下の形式で標準入力から与えられる。
N A_1 \ldots A_N M B_1 \ldots B_M L C_1 \ldots C_L Q X_1 \ldots X_Q
出力
Q 行出力せよ。
i 行目には、A,B,C からそれぞれ 1 個ずつ要素を選び和を X_i にすることができるならば Yes
、できないならば No
と出力せよ。
入力例 1
3 1 2 3 2 2 4 6 1 2 4 8 16 32 4 1 5 10 50
出力例 1
No Yes Yes No
- A,B,C からそれぞれ 1 個ずつ要素を選び和を 1 にすることはできません。
- A,B,C からそれぞれ 1,2,2 を選ぶと和を 5 にすることができます。
- A,B,C からそれぞれ 2,4,4 を選ぶと和を 10 にすることができます。
- A,B,C からそれぞれ 1 個ずつ要素を選び和を 50 にすることはできません。
Score: 250 points
Problem Statement
You are given three sequences A=(A_1,\ldots,A_N), B=(B_1,\ldots,B_M), and C=(C_1,\ldots,C_L).
Additionally, a sequence X=(X_1,\ldots,X_Q) is given. For each i=1,\ldots,Q, solve the following problem:
Problem: Is it possible to select one element from each of A, B, and C so that their sum is X_i?
Constraints
- 1 \leq N,M,L \leq 100
- 0 \leq A_i, B_i ,C_i \leq 10^8
- 1 \leq Q \leq 2\times 10^5
- 0 \leq X_i \leq 3\times 10^8
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N A_1 \ldots A_N M B_1 \ldots B_M L C_1 \ldots C_L Q X_1 \ldots X_Q
Output
Print Q lines.
The i-th line should contain Yes
if it is possible to select one element from each of A, B, and C so that their sum is X_i, and No
otherwise.
Sample Input 1
3 1 2 3 2 2 4 6 1 2 4 8 16 32 4 1 5 10 50
Sample Output 1
No Yes Yes No
- It is impossible to select one element from each of A, B, and C so that their sum is 1.
- Selecting 1, 2, and 2 from A, B, and C, respectively, makes the sum 5.
- Selecting 2, 4, and 4 from A, B, and C, respectively, makes the sum 10.
- It is impossible to select one element from each of A, B, and C so that their sum is 50.