Time Limit: 2 sec / Memory Limit: 256 MB
配点 : 100 点
問題文
a
,b
,c
からなる長さ 3 の文字列 S が与えられます。S を abc
を並び替えて作ることができるかどうか判定してください。
制約
- |S|=3
- S は
a
,b
,c
からなる
入力
入力は以下の形式で標準入力から与えられる。
S
出力
S を abc
を並び替えて作ることができるなら Yes
を、そうでないなら No
を出力せよ。
入力例 1
bac
出力例 1
Yes
bac
の 1 文字目と 2 文字目を入れ替えると abc
になります。
入力例 2
bab
出力例 2
No
入力例 3
abc
出力例 3
Yes
入力例 4
aaa
出力例 4
No
Score : 100 points
Problem Statement
You are given a string S of length 3 consisting of a
, b
and c
. Determine if S can be obtained by permuting abc
.
Constraints
- |S|=3
- S consists of
a
,b
andc
.
Input
Input is given from Standard Input in the following format:
S
Output
If S can be obtained by permuting abc
, print Yes
; otherwise, print No
.
Sample Input 1
bac
Sample Output 1
Yes
Swapping the first and second characters in bac
results in abc
.
Sample Input 2
bab
Sample Output 2
No
Sample Input 3
abc
Sample Output 3
Yes
Sample Input 4
aaa
Sample Output 4
No
Time Limit: 2 sec / Memory Limit: 256 MB
配点 : 200 点
問題文
以下を満たす整数をすべて昇順に出力してください。
- A 以上 B 以下の整数の中で、小さい方から K 番目以内であるか、大きい方から K 番目以内である
制約
- 1 \leq A \leq B \leq 10^9
- 1 \leq K \leq 100
- 入力はすべて整数である
入力
入力は以下の形式で標準入力から与えられる。
A B K
出力
上の条件を満たす整数をすべて昇順に出力せよ。
入力例 1
3 8 2
出力例 1
3 4 7 8
- 3 は 3 以上 8 以下の整数の中で小さい方から 1 番目です。
- 4 は 3 以上 8 以下の整数の中で小さい方から 2 番目です。
- 7 は 3 以上 8 以下の整数の中で大さい方から 2 番目です。
- 8 は 3 以上 8 以下の整数の中で大さい方から 1 番目です。
入力例 2
4 8 3
出力例 2
4 5 6 7 8
入力例 3
2 9 100
出力例 3
2 3 4 5 6 7 8 9
Score : 200 points
Problem Statement
Print all the integers that satisfies the following in ascending order:
- Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
Constraints
- 1 \leq A \leq B \leq 10^9
- 1 \leq K \leq 100
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
A B K
Output
Print all the integers that satisfies the condition above in ascending order.
Sample Input 1
3 8 2
Sample Output 1
3 4 7 8
- 3 is the first smallest integer among the integers between 3 and 8.
- 4 is the second smallest integer among the integers between 3 and 8.
- 7 is the second largest integer among the integers between 3 and 8.
- 8 is the first largest integer among the integers between 3 and 8.
Sample Input 2
4 8 3
Sample Output 2
4 5 6 7 8
Sample Input 3
2 9 100
Sample Output 3
2 3 4 5 6 7 8 9
Time Limit: 2 sec / Memory Limit: 256 MB
配点 : 300 点
問題文
3 つの整数 A,B,C が与えられます。以下の 2 種類の操作を好きな順で繰り返して A,B,C をすべて等しくするために必要な操作の最小回数を求めてください。
- A,B,C のうち 2 つを選んで、その両方を 1 増やす
- A,B,C のうち 1 つを選んで、その整数を 2 増やす
なお、これらの操作を繰り返して A,B,C をすべて等しくできることは証明できます。
制約
- 0 \leq A,B,C \leq 50
- 入力はすべて整数である
入力
入力は以下の形式で標準入力から与えられる。
A B C
出力
A,B,C をすべて等しくするために必要な操作の最小回数を出力せよ。
入力例 1
2 5 4
出力例 1
2
以下の操作で、A,B,C をすべて等しくできます。
- A,C を 1 増やす。A,B,C はそれぞれ 3,5,5 となる。
- A を 2 増やす。A,B,C はそれぞれ 5,5,5 となる。
入力例 2
2 6 3
出力例 2
5
入力例 3
31 41 5
出力例 3
23
Score : 300 points
Problem Statement
You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:
- Choose two among A, B and C, then increase both by 1.
- Choose one among A, B and C, then increase it by 2.
It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.
Constraints
- 0 \leq A,B,C \leq 50
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
A B C
Output
Print the minimum number of operations required to make A, B and C all equal.
Sample Input 1
2 5 4
Sample Output 1
2
We can make A, B and C all equal by the following operations:
- Increase A and C by 1. Now, A, B, C are 3, 5, 5, respectively.
- Increase A by 2. Now, A, B, C are 5, 5, 5, respectively.
Sample Input 2
2 6 3
Sample Output 2
5
Sample Input 3
31 41 5
Sample Output 3
23
Time Limit: 2 sec / Memory Limit: 256 MB
配点 : 700 点
問題文
高橋君を含めた 10^{10^{10}} 人の参加者が 2 回のプログラミングコンテストに参加しました。 各コンテストでは全員に 1 位から 10^{10^{10}} 位までの相異なる順位がつきました。
参加者のスコアとは、2 回のコンテストでの順位を掛け合わせた値です。
次のクエリ Q 個に答えてください。
- i 個目のクエリでは、2 つの正の整数 A_i,B_i が与えられる。高橋君が 1 回目のコンテストで A_i 位、2 回目のコンテストで B_i 位を取ったと仮定して、高橋君よりスコアの小さい参加者の人数の最大値を求めよ。
制約
- 1 \leq Q \leq 100
- 1\leq A_i,B_i\leq 10^9(1\leq i\leq Q)
- 入力はすべて整数である
入力
入力は以下の形式で標準入力から与えられる。
Q A_1 B_1 : A_Q B_Q
出力
クエリごとに、高橋君よりスコアの小さい参加者の人数の最大値を出力せよ。
入力例 1
8 1 4 10 5 3 3 4 11 8 9 22 40 8 36 314159265 358979323
出力例 1
1 12 4 11 14 57 31 671644785
1 回目のコンテストで x 位を、2 回目のコンテストで y 位を取った参加者を (x,y) で表すことにします。
1 つめのクエリでは、高橋君よりスコアの小さい参加者として (2,1) が考えられます。2 人以上のスコアが高橋君のスコアより小さくなることはないため、1 を出力します。
Score : 700 points
Problem Statement
10^{10^{10}} participants, including Takahashi, competed in two programming contests. In each contest, all participants had distinct ranks from first through 10^{10^{10}}-th.
The score of a participant is the product of his/her ranks in the two contests.
Process the following Q queries:
- In the i-th query, you are given two positive integers A_i and B_i. Assuming that Takahashi was ranked A_i-th in the first contest and B_i-th in the second contest, find the maximum possible number of participants whose scores are smaller than Takahashi's.
Constraints
- 1 \leq Q \leq 100
- 1\leq A_i,B_i\leq 10^9(1\leq i\leq Q)
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Q A_1 B_1 : A_Q B_Q
Output
For each query, print the maximum possible number of participants whose scores are smaller than Takahashi's.
Sample Input 1
8 1 4 10 5 3 3 4 11 8 9 22 40 8 36 314159265 358979323
Sample Output 1
1 12 4 11 14 57 31 671644785
Let us denote a participant who was ranked x-th in the first contest and y-th in the second contest as (x,y).
In the first query, (2,1) is a possible candidate of a participant whose score is smaller than Takahashi's. There are never two or more participants whose scores are smaller than Takahashi's, so we should print 1.