Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
AtCoder 国の暦では、1 年は 1 月から M 月までの M ヶ月からなり、どの月も 1 日から D 日までの D 日からなります。
AtCoder 国の暦で y 年 m 月 d 日の翌日は何年何月何日であるか求めてください。
制約
- 1000 \leq y \leq 9000
- 1 \leq m \leq M \leq 99
- 1 \leq d \leq D \leq 99
- 入力は全て整数である
入力
入力は以下の形式で標準入力から与えられる。
M D y m d
出力
AtCoder 国の暦で y 年 m 月 d 日の翌日が y' 年 m' 月 d' 日であるとき、y',m',d' をこの順に空白区切りで出力せよ。
入力例 1
12 30 2023 12 30
出力例 1
2024 1 1
AtCoder 国の暦では 1 年は 12 ヶ月であり、どの月も 30 日からなります。 よって、2023 年 12 月 30 日の翌日は 2024 年 1 月 1 日になります。
入力例 2
36 72 6789 23 45
出力例 2
6789 23 46
AtCoder 国の暦では 1 年は 36 ヶ月であり、どの月も 72 日からなります。 よって、6789 年 23 月 45 日の翌日は 6789 年 23 月 46 日になります。
入力例 3
12 30 2012 6 20
出力例 3
2012 6 21
Score : 100 points
Problem Statement
In the calendar of AtCoder Kingdom, a year consists of M months from month 1 to month M, and each month consists of D days from day 1 to day D.
What day follows year y, month m, day d in this calendar?
Constraints
- 1000 \leq y \leq 9000
- 1 \leq m \leq M \leq 99
- 1 \leq d \leq D \leq 99
- All input values are integers.
Input
The input is given from Standard Input in the following format:
M D y m d
Output
If the day following year y, month m, day d in the calendar of AtCoder Kingdom is year y', month m', day d', print y', m', and d' in this order, separated by spaces.
Sample Input 1
12 30 2023 12 30
Sample Output 1
2024 1 1
In the calendar of the kingdom, a year consists of 12 months, and each month consists of 30 days. Thus, the day following year 2023, month 12, day 30 is year 2024, month 1, day 1.
Sample Input 2
36 72 6789 23 45
Sample Output 2
6789 23 46
In the calendar of the kingdom, one year consists of 36 months, and each month consists of 72 days. Thus, the day following year 6789, month 23, day 45 is year 6789, month 23, day 46.
Sample Input 3
12 30 2012 6 20
Sample Output 3
2012 6 21
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
A を N 個、B を N 個、…、Z を N 個この順に繋げて得られる文字列の先頭から X 番目の文字を求めてください。
制約
- 1 \leq N \leq 100
- 1 \leq X \leq N\times 26
- 入力は全て整数
入力
入力は以下の形式で標準入力から与えられる。
N X
出力
答えを出力せよ。
入力例 1
1 3
出力例 1
C
得られる文字列は ABCDEFGHIJKLMNOPQRSTUVWXYZ です。先頭から 3 番目の文字は C です。
入力例 2
2 12
出力例 2
F
得られる文字列は AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYYZZ です。先頭から 12 番目の文字は F です。
Score : 100 points
Problem Statement
Find the X-th character from the beginning of the string that is obtained by concatenating these characters: N copies of A's, N copies of B's, …, and N copies of Z's, in this order.
Constraints
- 1 \leq N \leq 100
- 1 \leq X \leq N\times 26
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
N X
Output
Print the answer.
Sample Input 1
1 3
Sample Output 1
C
We obtain the string ABCDEFGHIJKLMNOPQRSTUVWXYZ, whose 3-rd character from the beginning is C.
Sample Input 2
2 12
Sample Output 2
F
We obtain the string AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYYZZ, whose 12-th character from the beginning is F.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
A 匹のスライムがいます。
すぬけくんが 1 回叫ぶたびに、スライムは K 倍に増殖します。
スライムが B 匹以上になるには、すぬけくんは最小で何回叫ぶ必要があるでしょうか?
制約
- 1 \leq A \leq B \leq 10^9
- 2 \leq K \leq 10^9
- 入力は全て整数
入力
入力は以下の形式で標準入力から与えられる。
A B K
出力
答えを出力せよ。
入力例 1
1 4 2
出力例 1
2
はじめ、スライムが 1 匹います。すぬけくんが 1 回叫ぶとスライムは 2 匹になり、 2 回叫ぶとスライムは 4 匹になります。4 匹以上になるためには、最小で 2 回叫ぶ必要があります。
入力例 2
7 7 10
出力例 2
0
はじめからスライムは 7 匹います。
入力例 3
31 415926 5
出力例 3
6
Score : 200 points
Problem Statement
There are A slimes.
Each time Snuke shouts, the slimes multiply by K times.
In order to have B or more slimes, at least how many times does Snuke need to shout?
Constraints
- 1 \leq A \leq B \leq 10^9
- 2 \leq K \leq 10^9
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
A B K
Output
Print the answer.
Sample Input 1
1 4 2
Sample Output 1
2
We start with one slime. After Snuke's first shout, we have two slimes; after his second shout, we have four slimes. Thus, he needs to shout at least twice to have four or more slimes.
Sample Input 2
7 7 10
Sample Output 2
0
We have seven slimes already at the start.
Sample Input 3
31 415926 5
Sample Output 3
6
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
N 人の人がいます。i \, (1 \leq i \leq N) 人目の人の姓は S_i、名は T_i です。
同姓同名であるような人の組が存在するか、すなわち 1 \leq i \lt j \leq N かつ S_i=S_j かつ T_i=T_j を満たすような整数対 (i,j) が存在するか判定してください。
制約
- 2 \leq N \leq 1000
- N は整数
- S_i,T_i は英小文字のみからなる長さ 1 以上 10 以下の文字列
入力
入力は以下の形式で標準入力から与えられる。
N
S_1 T_1
S_2 T_2
\hspace{0.6cm}\vdots
S_N T_N
出力
同姓同名であるような人の組が存在するなら Yes を、存在しないなら No を出力せよ。
入力例 1
3 tanaka taro sato hanako tanaka taro
出力例 1
Yes
1 人目の人と 3 人目の人が同姓同名です。
入力例 2
3 saito ichiro saito jiro saito saburo
出力例 2
No
同姓同名であるような人の組は存在しません。
入力例 3
4 sypdgidop bkseq bajsqz hh ozjekw mcybmtt qfeysvw dbo
出力例 3
No
Score : 200 points
Problem Statement
There are N people. The family name and given name of the i-th person (1 \leq i \leq N) are S_i and T_i, respectively.
Determine whether there is a pair of people with the same family and given names. In other words, determine whether there is a pair of integers (i,j) such that 1 \leq i \lt j \leq N, S_i=S_j, and T_i=T_j.
Constraints
- 2 \leq N \leq 1000
- N is an integer.
- Each of S_i and T_i is a string of length between 1 and 10 (inclusive) consisting of English lowercase letters.
Input
Input is given from Standard Input in the following format:
N
S_1 T_1
S_2 T_2
\hspace{0.6cm}\vdots
S_N T_N
Output
If there is a pair of people with the same family and given names, print Yes; otherwise, print No.
Sample Input 1
3 tanaka taro sato hanako tanaka taro
Sample Output 1
Yes
The first and third persons have the same family and given names.
Sample Input 2
3 saito ichiro saito jiro saito saburo
Sample Output 2
No
No two persons have the same family and given names.
Sample Input 3
4 sypdgidop bkseq bajsqz hh ozjekw mcybmtt qfeysvw dbo
Sample Output 3
No
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 300 点
問題文
10 進法で表記したときに 0,2 のみからなる正整数のうち、 K 番目に小さいものを求めてください。
制約
- K は 1 以上 10^{18} 以下の整数
入力
入力は以下の形式で標準入力から与えられる。
K
出力
答えを整数として出力せよ。
ただし、たとえ答えが大きな整数であっても、求める答えを正確に整数として出力する必要がある。たとえば、 2.34e+22 のような指数表記や、 0523 のような先頭に不要な 0 を付けたような表記は許されない。
入力例 1
3
出力例 1
22
10 進法で表記した時に 0,2 のみからなる正整数を小さい方から並べると、 2,20,22,\dots となります。
このうち K=3 番目である 22 を出力してください。
入力例 2
11
出力例 2
2022
入力例 3
923423423420220108
出力例 3
220022020000202020002022022000002020002222002200002022002200
たとえ答えが大きな整数であっても、求める答えを正確に整数として出力する必要があることに注意してください。
Score : 300 points
Problem Statement
Among the positive integers that consist of 0's and 2's when written in base 10, find the K-th smallest integer.
Constraints
- K is an integer between 1 and 10^{18} (inclusive).
Input
Input is given from Standard Input in the following format:
K
Output
Print the answer as an integer.
Here, the exact value must be printed as an integer, even if it is big. Exponential notations such as 2.34e+22, for example, or unnecessary leading zeros such as 0523 are not allowed.
Sample Input 1
3
Sample Output 1
22
The positive integers that consist of 0's and 2's when written in base 10 are 2,20,22,\dots in ascending order.
The (K=) 3-rd of them, which is 22, should be printed.
Sample Input 2
11
Sample Output 2
2022
Sample Input 3
923423423420220108
Sample Output 3
220022020000202020002022022000002020002222002200002022002200
Note that the exact value of the answer must be printed as an integer, even if it is big.