実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 100 点
問題文
1 以上 9 以下の数字 A,B,C が与えられます。
A,B,C を好きな順番で並べて繋げることで作れる 3 桁の整数のうち、値が最大のものを求めてください。
制約
- A,B,C は 1 以上 9 以下の数字
入力
入力は以下の形式で標準入力から与えられる。
A B C
出力
答えを出力せよ。
入力例 1
3 2 4
出力例 1
432
A,B,C を好きな順番で並べて繋げることで作れる 3 桁の整数は 324, 342, 234, 243, 432, 423 の 6 通りであり、 このうち値が最大のものは 432 です。
入力例 2
7 7 7
出力例 2
777
777 のみを作ることができます。
入力例 3
9 1 9
出力例 3
991
Score : 100 points
Problem Statement
You are given three digits A,B,C between 1 and 9, inclusive.
Find the maximum value among all 3-digit integers that can be formed by arranging A,B,C in any order and concatenating them.
Constraints
- A,B,C are digits between 1 and 9, inclusive.
Input
The input is given from Standard Input in the following format:
A B C
Output
Output the answer.
Sample Input 1
3 2 4
Sample Output 1
432
There are six 3-digit integers that can be formed by arranging A,B,C in any order and concatenating them: 324, 342, 234, 243, 432, 423; the maximum value among them is 432.
Sample Input 2
7 7 7
Sample Output 2
777
Only 777 can be formed.
Sample Input 3
9 1 9
Sample Output 3
991
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 100 点
問題文
100 以上の整数 N が与えられます。N の下 2 桁を出力してください。
ただし、N の下 2 桁とは十の位と一の位をこの順に並べたものを言います。
制約
- 100 \le N \le 999
- N は整数である。
入力
入力は以下の形式で標準入力から与えられる。
N
出力
答えを出力せよ。
入力例 1
254
出力例 1
54
254 の下 2 桁は 54 であるため、54 を出力します。
入力例 2
101
出力例 2
01
101 の下 2 桁は 01 であるため、01 を出力します。
Score : 100 points
Problem Statement
You are given an integer N at least 100. Print the last two digits of N.
Strictly speaking, print the tens and ones digits of N in this order.
Constraints
- 100 \le N \le 999
- N is an integer.
Input
Input is given from Standard Input in the following format:
N
Output
Print the answer.
Sample Input 1
254
Sample Output 1
54
The last two digits of 254 are 54, which should be printed.
Sample Input 2
101
Sample Output 2
01
The last two digits of 101 are 01, which should be printed.
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 200 点
問題文
英大文字と英小文字からなる文字列のうち、以下の条件を全て満たすものを素晴らしい文字列ということとします。
- 英大文字が文字列の中に現れる。
- 英小文字が文字列の中に現れる。
- 全ての文字が相異なる。
例えば、AtCoder や Aa は素晴らしい文字列ですが、atcoder や Perfect は素晴らしい文字列ではありません。
文字列 S が与えられるので、S が素晴らしい文字列か判定してください。
制約
- 1 \le |S| \le 100
- S は英大文字と英小文字からなる文字列である。
入力
入力は以下の形式で標準入力から与えられる。
S
出力
S が素晴らしい文字列ならば Yes を、そうでないならば No を出力せよ。
入力例 1
AtCoder
出力例 1
Yes
AtCoder は、英大文字が含まれ、英小文字も含まれ、かつ全ての文字が相異なるため素晴らしい文字列です。
入力例 2
Aa
出力例 2
Yes
A と a は違う文字であることに注意してください。この文字列は素晴らしい文字列です。
入力例 3
atcoder
出力例 3
No
英大文字が含まれていないため、素晴らしい文字列ではありません。
入力例 4
Perfect
出力例 4
No
2 文字目と 5 文字目が等しいため、素晴らしい文字列ではありません。
Score : 200 points
Problem Statement
Let us call a string consisting of uppercase and lowercase English alphabets a wonderful string if all of the following conditions are satisfied:
- The string contains an uppercase English alphabet.
- The string contains a lowercase English alphabet.
- All characters in the string are pairwise distinct.
For example, AtCoder and Aa are wonderful strings, while atcoder and Perfect are not.
Given a string S, determine if S is a wonderful string.
Constraints
- 1 \le |S| \le 100
- S is a string consisting of uppercase and lowercase English alphabets.
Input
Input is given from Standard Input in the following format:
S
Output
If S is a wonderful string, print Yes; otherwise, print No.
Sample Input 1
AtCoder
Sample Output 1
Yes
AtCoder is a wonderful string because it contains an uppercase English alphabet, a lowercase English alphabet, and all characters in the string are pairwise distinct.
Sample Input 2
Aa
Sample Output 2
Yes
Note that A and a are different characters. This string is a wonderful string.
Sample Input 3
atcoder
Sample Output 3
No
It is not a wonderful string because it does not contain an uppercase English alphabet.
Sample Input 4
Perfect
Sample Output 4
No
It is not a wonderful string because the 2-nd and the 5-th characters are the same.
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 200 点
問題文
長さ N の正整数列 A=(A_1,A_2,\ldots,A_N) が与えられます。
A が等比数列であるか判定してください。
制約
- 2\leq N\leq 100
- 1\leq A_i\leq 10^9
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N A_1 A_2 \ldots A_N
出力
A が 等比数列ならば Yes を、そうでないならば No を出力せよ。
入力例 1
5 3 6 12 24 48
出力例 1
Yes
A=(3,6,12,24,48) です。
A は初項 3, 公比 2, 項数 5 の等比数列となっています。
よって、Yes を出力します。
入力例 2
3 1 2 3
出力例 2
No
A=(1,2,3) です。
A_1:A_2=1:2\neq 2:3=A_2:A_3 より、A は等比数列ではありません。
よって、No を出力します。
入力例 3
2 10 8
出力例 3
Yes
A は初項 10, 公比 0.8, 項数 2 の等比数列となっています。
よって、Yes を出力します。
Score : 200 points
Problem Statement
You are given a length-N sequence A=(A_1,A_2,\ldots,A_N) of positive integers.
Determine whether A is a geometric progression.
Constraints
- 2 \leq N \leq 100
- 1 \leq A_i \leq 10^9
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N A_1 A_2 \ldots A_N
Output
If A is a geometric progression, print Yes; otherwise, print No.
Sample Input 1
5 3 6 12 24 48
Sample Output 1
Yes
A=(3,6,12,24,48).
A is a geometric progression with first term 3, common ratio 2, and five terms.
Therefore, print Yes.
Sample Input 2
3 1 2 3
Sample Output 2
No
A=(1,2,3).
Since A_1 : A_2 = 1 : 2 \neq 2 : 3 = A_2 : A_3, A is not a geometric progression.
Therefore, print No.
Sample Input 3
2 10 8
Sample Output 3
Yes
A is a geometric progression with first term 10, common ratio 0.8, and two terms.
Therefore, print Yes.
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 300 点
問題文
以下の条件を満たす長さ N の整数列を辞書順で小さい方から順に全て出力して下さい。
- i 番目の要素は 1 以上 R_i 以下
- 総和が K の倍数
数列の辞書順とは?
数列 A = (A_1, \ldots, A_{|A|}) が B = (B_1, \ldots, B_{|B|}) より辞書順で真に小さいとは、下記の 1. と 2. のどちらかが成り立つことを言います。- |A|<|B| かつ (A_{1},\ldots,A_{|A|}) = (B_1,\ldots,B_{|A|}) である。
- ある整数 1\leq i\leq \min\{|A|,|B|\} が存在して、下記の 2 つがともに成り立つ。
- (A_{1},\ldots,A_{i-1}) = (B_1,\ldots,B_{i-1})
- A_i < B_i
制約
- 入力は全て整数
- 1 \le N \le 8
- 2 \le K \le 10
- 1 \le R_i \le 5
入力
入力は以下の形式で標準入力から与えられる。
N K R_1 R_2 \dots R_N
出力
出力すべき数列が X 個あり、そのうち i 個目が A_i=(A_{i,1},A_{i,2},\dots,A_{i,N}) であったとき、答えを以下の形式で出力せよ。
A_{1,1} A_{1,2} \dots A_{1,N}
A_{2,1} A_{2,2} \dots A_{2,N}
\vdots
A_{X,1} A_{X,2} \dots A_{X,N}
入力例 1
3 2 2 1 3
出力例 1
1 1 2 2 1 1 2 1 3
出力すべき数列は 3 個で、辞書順で (1,1,2),(2,1,1),(2,1,3) です。
入力例 2
1 2 1
出力例 2
出力すべき数列が無い場合もあります。
この場合、出力は空で構いません。
入力例 3
5 5 2 3 2 3 2
出力例 3
1 1 1 1 1 1 2 2 3 2 1 3 1 3 2 1 3 2 2 2 1 3 2 3 1 2 1 2 3 2 2 2 1 3 2 2 2 2 2 2 2 2 2 3 1 2 3 1 2 2 2 3 1 3 1 2 3 2 1 2 2 3 2 2 1
Score : 300 points
Problem Statement
Print all integer sequences of length N that satisfy the following conditions, in ascending lexicographical order.
- The i-th element is between 1 and R_i, inclusive.
- The sum of all elements is a multiple of K.
What is lexicographical order for sequences?
A sequence A = (A_1, \ldots, A_{|A|}) is lexicographically smaller than B = (B_1, \ldots, B_{|B|}) if either 1. or 2. below holds:- |A|<|B| and (A_{1},\ldots,A_{|A|}) = (B_1,\ldots,B_{|A|}).
- There exists an integer 1\leq i\leq \min\{|A|,|B|\} such that both of the following are true:
- (A_{1},\ldots,A_{i-1}) = (B_1,\ldots,B_{i-1})
- A_i < B_i
Constraints
- All input values are integers.
- 1 \le N \le 8
- 2 \le K \le 10
- 1 \le R_i \le 5
Input
The input is given from Standard Input in the following format:
N K R_1 R_2 \dots R_N
Output
Print the answer in the following format, where X is the number of sequences to print, the i-th of which is A_i=(A_{i,1},A_{i,2},\dots,A_{i,N}):
A_{1,1} A_{1,2} \dots A_{1,N}
A_{2,1} A_{2,2} \dots A_{2,N}
\vdots
A_{X,1} A_{X,2} \dots A_{X,N}
Sample Input 1
3 2 2 1 3
Sample Output 1
1 1 2 2 1 1 2 1 3
There are three sequences to be printed, which are (1,1,2),(2,1,1),(2,1,3) in lexicographical order.
Sample Input 2
1 2 1
Sample Output 2
There may be no sequences to print.
In this case, the output can be empty.
Sample Input 3
5 5 2 3 2 3 2
Sample Output 3
1 1 1 1 1 1 2 2 3 2 1 3 1 3 2 1 3 2 2 2 1 3 2 3 1 2 1 2 3 2 2 2 1 3 2 2 2 2 2 2 2 2 2 3 1 2 3 1 2 2 2 3 1 3 1 2 3 2 1 2 2 3 2 2 1