Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
整数 a, b, c が与えられます。b がこれらの整数の中央値であるかどうか判定してください。
制約
- 1 \leq a, b, c \leq 100
- 入力は全て整数
入力
入力は以下の形式で標準入力から与えられる。
a b c
出力
b が与えられた整数の中央値であるならば Yes、そうでないならば No と出力せよ。
入力例 1
5 3 2
出力例 1
Yes
与えられた整数を小さい順に並べると 2, 3, 5 となり、b はこれらの整数の中央値です。
入力例 2
2 5 3
出力例 2
No
b は与えられた整数の中央値ではありません。
入力例 3
100 100 100
出力例 3
Yes
Score : 100 points
Problem Statement
Given integers a, b, and c, determine if b is the median of these integers.
Constraints
- 1 \leq a, b, c \leq 100
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
a b c
Output
If b is the median of the given integers, then print Yes; otherwise, print No.
Sample Input 1
5 3 2
Sample Output 1
Yes
The given integers are 2, 3, 5 when sorted in ascending order, of which b is the median.
Sample Input 2
2 5 3
Sample Output 2
No
b is not the median of the given integers.
Sample Input 3
100 100 100
Sample Output 3
Yes
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
0 と 1 からなる長さ 16 の文字列 S が与えられます。
2 以上 16 以下のすべての偶数 i について S の i 文字目が 0 ならば Yes を、
そうでないならば No を出力してください。 
制約
- S は 0と1からなる長さ 16 の文字列
入力
入力は以下の形式で標準入力から与えられる。
S
出力
2 以上 16 以下のすべての偶数 i について S の i 文字目が 0 ならば Yes を、
そうでないならば No を出力せよ。
入力例 1
1001000000001010
出力例 1
No
S= 1001000000001010 の 4 文字目が 1 であるため、No を出力します。 
入力例 2
1010100000101000
出力例 2
Yes
S= 1010100000101000 の偶数番目の文字はすべて 0 であるため、Yes を出力します。
入力例 3
1111111111111111
出力例 3
No
S の偶数文字目はすべて 1 となっています。
特に「すべて 0 」ではないため、No を出力します。 
Score : 100 points
Problem Statement
You are given a string S of length 16 consisting of 0 and 1.
If the i-th character of S is 0 for every even number i from 2 through 16, print Yes; otherwise, print No.
Constraints
- S is a string of length 16 consisting of 0and1.
Input
The input is given from Standard Input in the following format:
S
Output
If the i-th character of S is 0 for every even number i from 2 through 16, print Yes; otherwise, print No.
Sample Input 1
1001000000001010
Sample Output 1
No
The 4-th character of S= 1001000000001010 is 1, so you should print No. 
Sample Input 2
1010100000101000
Sample Output 2
Yes
Every even-positioned character in S= 1010100000101000 is 0, so you should print Yes.
Sample Input 3
1111111111111111
Sample Output 3
No
Every even-positioned character in S is 1.
Particularly, they are not all 0, so you should print No.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
正整数 A,B が与えられます。
A+B を(十進法で)計算する時、繰り上がりが生じないなら Easy 、生じるなら Hard と出力してください。
制約
- A,B は整数
- 1 \le A,B \le 10^{18}
入力
入力は以下の形式で標準入力から与えられる。
A B
出力
繰り上がりが生じないなら Easy 、生じるなら Hard と出力せよ。
入力例 1
229 390
出力例 1
Hard
229+390 を計算する際、十の位から百の位へと繰り上がりが発生します。よって、答えは Hard です。
入力例 2
123456789 9876543210
出力例 2
Easy
繰り上がりは発生しません。答えは Easy です。
また、入力が 32bit 整数に収まらないこともあります。  
Score : 200 points
Problem Statement
You are given positive integers A and B.
Let us calculate A+B (in decimal). If it does not involve a carry, print Easy; if it does, print Hard.
Constraints
- A and B are integers.
- 1 \le A,B \le 10^{18}
Input
Input is given from Standard Input in the following format:
A B
Output
If the calculation does not involve a carry, print Easy; if it does, print Hard.
Sample Input 1
229 390
Sample Output 1
Hard
When calculating 229+390, we have a carry from the tens digit to the hundreds digit, so the answer is Hard.
Sample Input 2
123456789 9876543210
Sample Output 2
Easy
We do not have a carry here; the answer is Easy.
Note that the input may not fit into a 32-bit integer.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
正の整数 X に対して、X を 2 進表記したときに 末尾 に連続する 0 の個数(の最大値)を \text{ctz}(X) で表します。
ただし、X を 2 進表記したとき末尾が 1 ならば \text{ctz}(X)=0 です。
正の整数 N が与えられるので、\text{ctz}(N) を出力してください。
制約
- 1\leq N\leq 10^9
- N は整数
入力
入力は以下の形式で標準入力から与えられる。
N
出力
\text{ctz}(N) を出力せよ。
入力例 1
2024
出力例 1
3
2024 を 2 進表記すると 11111101000 であり、末尾から 0 が 3 個連続しているため、\text{ctz}(2024)=3 です。
よって、3 を出力します。
入力例 2
18
出力例 2
1
18 を 2 進表記すると 10010 であるため、\text{ctz}(18)=1 です。
0 は末尾から連続する必要があることに注意してください。
入力例 3
5
出力例 3
0
Score: 200 points
Problem Statement
For a positive integer X, let \text{ctz}(X) be the (maximal) number of consecutive zeros at the end of the binary notation of X.
If the binary notation of X ends with a 1, then \text{ctz}(X)=0.
You are given a positive integer N. Print \text{ctz}(N).
Constraints
- 1\leq N\leq 10^9
- N is an integer.
Input
The input is given from Standard Input in the following format:
N
Output
Print \text{ctz}(N).
Sample Input 1
2024
Sample Output 1
3
2024 is 11111101000 in binary, with three consecutive 0s from the end, so \text{ctz}(2024)=3.
Thus, print 3.
Sample Input 2
18
Sample Output 2
1
18 is 10010 in binary, so \text{ctz}(18)=1.
Note that we count the trailing zeros.
Sample Input 3
5
Sample Output 3
0
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 300 点
問題文
あなたはアメーバの観察記録をつけました。
最初 1 匹のアメーバがおり、番号は 1 です。
観察記録は時系列順に N 個あり、i 番目の観察記録は「番号 A_i のアメーバが分裂して消滅し、新たに 2 匹のアメーバが生まれ、それらにそれぞれ 2i,2i+1 と番号をつけた」というものです。
このとき、アメーバ A_i を アメーバ 2i,2i+1 の親と呼びます。
各 k=1,\ldots,2N+1 について、アメーバ k から何代親を遡るとアメーバ 1 になるか求めてください。
制約
- 1 \leq N \leq 2\times 10^5
- 観察記録は矛盾していない。すなわち- 1\leq A_i \leq 2i-1
- A_i は相異なる整数
 
入力
入力は以下の形式で標準入力から与えられる。
N A_1 A_2 \ldots A_N
出力
2N+1 行出力せよ。k 行目にはアメーバ k から何代親を遡るとアメーバ 1 になるかを出力せよ。
入力例 1
2 1 2
出力例 1
0 1 1 2 2
アメーバ 1 からアメーバ 2,3 が生まれ、アメーバ 2 からアメーバ 4,5 が生まれました。
- アメーバ 1 は 0 代遡るとアメーバ 1 になります。
- アメーバ 2 は 1 代遡るとアメーバ 1 になります。
- アメーバ 3 は 1 代遡るとアメーバ 1 になります。
- アメーバ 4 は 1 代遡るとアメーバ 2 になり、2 代遡るとアメーバ 1 になります。
- アメーバ 5 は 1 代遡るとアメーバ 2 になり、2 代遡るとアメーバ 1 になります。
入力例 2
4 1 3 5 2
出力例 2
0 1 1 2 2 3 3 2 2
Score : 300 points
Problem Statement
You observed amoebae and kept some records.
Initially, there was one amoeba, numbered 1.
You made N records. According to the i-th record, the amoeba numbered A_i disappeared by dividing itself into two new amoebae, which were then numbered 2i and 2i+1.
Here, amoeba A_i is said to be the parent of amoebae 2i and 2i+1.
For each k=1,\ldots,2N+1, how many generations away is amoeba k from amoeba 1?
Constraints
- 1 \leq N \leq 2\times 10^5
- The records are consistent. That is:- 1\leq A_i \leq 2i-1.
- A_i are distinct integers.
 
Input
The input is given from Standard Input in the following format:
N A_1 A_2 \ldots A_N
Output
Print 2N+1 lines. The k-th line should contain the generation distance between amoeba 1 and amoeba k.
Sample Input 1
2 1 2
Sample Output 1
0 1 1 2 2
From amoeba 1, amoebae 2 and 3 were born. From amoeba 2, amoebae 4 and 5 were born.
- Amoeba 1 is zero generations away from amoeba 1.
- Amoeba 2 is one generation away from amoeba 1.
- Amoeba 3 is one generation away from amoeba 1.
- Amoeba 4 is one generation away from amoeba 2, and two generations away from amoeba 1.
- Amoeba 5 is one generation away from amoeba 2, and two generations away from amoeba 1.
Sample Input 2
4 1 3 5 2
Sample Output 2
0 1 1 2 2 3 3 2 2