実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 100 点
問題文
文字列 S が与えられます。ここで、S の 1 文字目は英大文字、2 文字目以降は英小文字です。
S の 1 文字目と UPC をこの順に結合した文字列を出力してください。
制約
- S は長さ 1 以上 100 以下の文字列
- S の 1 文字目は英大文字
- S の 2 文字目以降は英小文字
入力
入力は以下の形式で標準入力から与えられる。
S
出力
S の 1 文字目と UPC をこの順に結合した文字列を出力せよ。
入力例 1
Kyoto
出力例 1
KUPC
Kyoto の 1 文字目は K であるため、K と UPC を結合した KUPC を出力します。
入力例 2
Tohoku
出力例 2
TUPC
Score : 100 points
Problem Statement
You are given a string S. Here, the first character of S is an uppercase English letter, and the second and subsequent characters are lowercase English letters.
Print the string formed by concatenating the first character of S and UPC in this order.
Constraints
- S is a string of length between 1 and 100, inclusive.
- The first character of S is an uppercase English letter.
- The second and subsequent characters of S are lowercase English letters.
Input
The input is given from Standard Input in the following format:
S
Output
Print the string formed by concatenating the first character of S and UPC in this order.
Sample Input 1
Kyoto
Sample Output 1
KUPC
The first character of Kyoto is K, so concatenate K and UPC, and print KUPC.
Sample Input 2
Tohoku
Sample Output 2
TUPC
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 100 点
問題文
数字からなる文字列 S が与えられます。
S から 2 以外の文字を削除し、残った文字を順序を保って結合した文字列を求めてください。
制約
- S は数字からなる長さ 1 以上 100 以下の文字列
- S は
2を 1 つ以上含む
入力
入力は以下の形式で標準入力から与えられる。
S
出力
答えを出力せよ。
入力例 1
20250222
出力例 1
22222
20250222 から 0, 5, 0 を削除し、残った文字を順序を保って結合することで文字列 22222 が得られます。
入力例 2
2
出力例 2
2
入力例 3
22222000111222222
出力例 3
22222222222
Score : 100 points
Problem Statement
You are given a string S consisting of digits.
Remove all characters from S except for 2, and then concatenate the remaining characters in their original order to form a new string.
Constraints
- S is a string consisting of digits with length between 1 and 100, inclusive.
- S contains at least one
2.
Input
The input is given from Standard Input in the following format:
S
Output
Print the answer.
Sample Input 1
20250222
Sample Output 1
22222
By removing 0, 5, and 0 from 20250222 and then concatenating the remaining characters in their original order, the string 22222 is obtained.
Sample Input 2
2
Sample Output 2
2
Sample Input 3
22222000111222222
Sample Output 3
22222222222
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 200 点
問題文
数直線の原点に高橋君がいます。高橋君は座標 X にあるゴールに移動しようとしています。
座標 Y には壁があり、最初、高橋君は壁を超えて移動することができません。
座標 Z にあるハンマーを拾った後でなら、壁を破壊して通過できるようになります。
高橋君がゴールに到達することが可能か判定し、可能であれば移動距離の最小値を求めてください。
制約
- -1000 \leq X,Y,Z \leq 1000
- X,Y,Z は相異なり、いずれも 0 でない
- 入力に含まれる値は全て整数である
入力
入力は以下の形式で標準入力から与えられる。
X Y Z
出力
高橋君がゴールに到達することが可能であれば、移動距離の最小値を出力せよ。不可能であれば、かわりに -1 と出力せよ。
入力例 1
10 -10 1
出力例 1
10
高橋君はまっすぐゴールに向かうことができます。
入力例 2
20 10 -10
出力例 2
40
ゴールは壁の向こう側にあります。まずハンマーを拾い、壁を壊すことでゴールに到達することができます。
入力例 3
100 1 1000
出力例 3
-1
Score : 200 points
Problem Statement
Takahashi is at the origin of a number line. He wants to reach a goal at coordinate X.
There is a wall at coordinate Y, which Takahashi cannot go beyond at first.
However, after picking up a hammer at coordinate Z, he can destroy that wall and pass through.
Determine whether Takahashi can reach the goal. If he can, find the minimum total distance he needs to travel to do so.
Constraints
- -1000 \leq X,Y,Z \leq 1000
- X, Y, and Z are distinct, and none of them is 0.
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
X Y Z
Output
If Takahashi can reach the goal, print the minimum total distance he needs to travel to do so. If he cannot, print -1 instead.
Sample Input 1
10 -10 1
Sample Output 1
10
Takahashi can go straight to the goal.
Sample Input 2
20 10 -10
Sample Output 2
40
The goal is beyond the wall. He can get there by first picking up the hammer and then destroying the wall.
Sample Input 3
100 1 1000
Sample Output 3
-1
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 200 点
問題文
整数 N が与えられます。
以下の指示に従って N の近似値を出力してください。
- N が 10^3-1 以下ならば、N をそのまま出力する。
- N が 10^3 以上 10^4-1 以下ならば、N の一の位を切り捨てて出力する。
- N が 10^4 以上 10^5-1 以下ならば、N の十の位以下を切り捨てて出力する。
- N が 10^5 以上 10^6-1 以下ならば、N の百の位以下を切り捨てて出力する。
- N が 10^6 以上 10^7-1 以下ならば、N の千の位以下を切り捨てて出力する。
- N が 10^7 以上 10^8-1 以下ならば、N の一万の位以下を切り捨てて出力する。
- N が 10^8 以上 10^9-1 以下ならば、N の十万の位以下を切り捨てて出力する。
制約
- N は 0 以上 10^9-1 以下の整数
入力
入力は以下の形式で標準入力から与えられる。
N
出力
答えを出力せよ。
入力例 1
20230603
出力例 1
20200000
20230603 は 10^7 以上 10^8-1 以下です。
したがって、一万以下の位を切り捨てて 20200000 を出力します。
入力例 2
0
出力例 2
0
入力例 3
304
出力例 3
304
入力例 4
500600
出力例 4
500000
Score : 200 points
Problem Statement
You are given an integer N.
Print an approximation of N according to the following instructions.
- If N is less than or equal to 10^3-1, print N as it is.
- If N is between 10^3 and 10^4-1, inclusive, truncate the ones digit of N and print the result.
- If N is between 10^4 and 10^5-1, inclusive, truncate the tens digit and all digits below it of N and print the result.
- If N is between 10^5 and 10^6-1, inclusive, truncate the hundreds digit and all digits below it of N and print the result.
- If N is between 10^6 and 10^7-1, inclusive, truncate the thousands digit and all digits below it of N and print the result.
- If N is between 10^7 and 10^8-1, inclusive, truncate the ten-thousands digit and all digits below it of N and print the result.
- If N is between 10^8 and 10^9-1, inclusive, truncate the hundred-thousands digit and all digits below it of N and print the result.
Constraints
- N is an integer between 0 and 10^9-1, inclusive.
Input
The input is given from Standard Input in the following format:
N
Output
Print the answer.
Sample Input 1
20230603
Sample Output 1
20200000
20230603 is between 10^7 and 10^8-1 (inclusive).
Therefore, truncate the ten-thousands digit and all digits below it, and print 20200000.
Sample Input 2
0
Sample Output 2
0
Sample Input 3
304
Sample Output 3
304
Sample Input 4
500600
Sample Output 4
500000
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 300 点
問題文
高橋くんは数直線上に N 個のプレゼントを置きました。そのうち i 個目のプレゼントは座標 A_i に置かれました。
あなたは数直線上の長さ M の半開区間 [x,x+M) を選び、そこに含まれるプレゼントを全て獲得します。
より詳しくは、以下の手順でプレゼントを獲得します。
- まず、実数 x をひとつ選択する。
- その後、プレゼントのうち置かれている座標が x \le A_i < x+M を満たすものを全て獲得する。
最大でいくつのプレゼントを獲得することができますか?
制約
- 入力は全て整数
- 1 \le N \le 3 \times 10^5
- 1 \le M \le 10^9
- 0 \le A_i \le 10^9
入力
入力は以下の形式で標準入力から与えられる。
N M A_1 A_2 \dots A_N
出力
答えを整数として出力せよ。
入力例 1
8 6 2 3 5 7 11 13 17 19
出力例 1
4
例えば、半開区間 [1.5,7.5) を指定します。
このとき、座標 2,3,5,7 にある 4 つのプレゼントを全て獲得することができ、これが獲得可能な最大の個数です。
入力例 2
10 1 3 1 4 1 5 9 2 6 5 3
出力例 2
2
同一の座標に複数のプレゼントが置いてあることもあります。
入力例 3
10 998244353 100000007 0 1755647 998244353 495 1000000000 1755648 503 1755649 998244853
出力例 3
7
Score : 300 points
Problem Statement
Takahashi has placed N gifts on a number line. The i-th gift is placed at coordinate A_i.
You will choose a half-open interval [x,x+M) of length M on the number line and acquire all the gifts included in it.
More specifically, you acquire gifts according to the following procedure.
- First, choose one real number x.
- Then, acquire all the gifts whose coordinates satisfy x \le A_i < x+M.
What is the maximum number of gifts you can acquire?
Constraints
- All input values are integers.
- 1 \le N \le 3 \times 10^5
- 1 \le M \le 10^9
- 0 \le A_i \le 10^9
Input
The input is given from Standard Input in the following format:
N M A_1 A_2 \dots A_N
Output
Print the answer as an integer.
Sample Input 1
8 6 2 3 5 7 11 13 17 19
Sample Output 1
4
For example, specify the half-open interval [1.5,7.5).
In this case, you can acquire the four gifts at coordinates 2,3,5,7, the maximum number of gifts that can be acquired.
Sample Input 2
10 1 3 1 4 1 5 9 2 6 5 3
Sample Output 2
2
There may be multiple gifts at the same coordinate.
Sample Input 3
10 998244353 100000007 0 1755647 998244353 495 1000000000 1755648 503 1755649 998244853
Sample Output 3
7