Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
高橋君が 100 階建てのビルにいます。
高橋君は 2 階分までの上り、または、3 階分までの下りであれば移動には階段を使い、そうでないときエレベーターを使います。
高橋君が X 階から Y 階への移動に使うのは階段ですか?
制約
- 1 \leq X,Y \leq 100
- X \neq Y
- 入力は全ては整数である
入力
入力は以下の形式で標準入力から与えられる。
X Y
出力
移動に使うのが階段ならば Yes、エレベーターならば No を出力せよ。
入力例 1
1 4
出力例 1
No
1 階から 4 階への移動は 3 階分の上りなのでエレベーターを使います。
入力例 2
99 96
出力例 2
Yes
99 階から 96 階への移動は 3 階分の下りなので階段を使います。
入力例 3
100 1
出力例 3
No
Score : 100 points
Problem Statement
Takahashi is in a building with 100 floors.
He uses the stairs for moving up two floors or less or moving down three floors or less, and uses the elevator otherwise.
Does he use the stairs to move from floor X to floor Y?
Constraints
- 1 \leq X,Y \leq 100
- X \neq Y
- All input values are integers.
Input
The input is given from Standard Input in the following format:
X Y
Output
If Takahashi uses the stairs for the move, print Yes; if he uses the elevator, print No.
Sample Input 1
1 4
Sample Output 1
No
The move from floor 1 to floor 4 involves going up three floors, so Takahashi uses the elevator.
Sample Input 2
99 96
Sample Output 2
Yes
The move from floor 99 to floor 96 involves going down three floors, so Takahashi uses the stairs.
Sample Input 3
100 1
Sample Output 3
No
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
英小文字 a, b, \ldots, z の ASCII 文字コードはこの順に 97,98,\ldots,122 です。
97 以上 122 以下の整数 N が与えられるので、ASCII 文字コードが N であるような英小文字を出力してください。
制約
- N は 97 以上 122 以下の整数
入力
入力は以下の形式で標準入力から与えられる。
N
出力
答えを出力せよ。
入力例 1
97
出力例 1
a
ASCII 文字コードが 97 である英小文字は a です。
入力例 2
122
出力例 2
z
Score : 100 points
Problem Statement
The ASCII values of the lowercase English letters a, b, \ldots, z are 97,98,\ldots,122 in this order.
Given an integer N between 97 and 122, print the letter whose ASCII value is N.
Constraints
- N is an integer between 97 and 122 (inclusive).
Input
Input is given from Standard Input in the following format:
N
Output
Print the answer.
Sample Input 1
97
Sample Output 1
a
97 is the ASCII value of a.
Sample Input 2
122
Sample Output 2
z
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 250 点
問題文
H 行 W 列のグリッドがあり、はじめすべてのマスが白で塗られています。グリッドの上から i 行目、左から j 列目のマスを (i, j) と表記します。
このグリッドはトーラス状であるとみなします。すなわち、各 1 \leq i \leq H に対して (i, W) の右に (i, 1) があり、各 1 \leq j \leq W に対して (H, j) の下に (1, j) があるとします。
高橋君が (1, 1) にいて上を向いています。高橋君が以下の操作を N 回繰り返した後のグリッドの各マスがどの色で塗られているか出力してください。
- 現在いるマスが白で塗られている場合は、現在いるマスを黒に塗り替え、時計回りに 90^\circ 回転し、向いている方向に 1 マス進む。そうでない場合は、現在いるマスを白に塗り替え、反時計回りに 90^\circ 回転し、向いている方向に 1 マス進む。
制約
- 1 \leq H, W \leq 100
- 1 \leq N \leq 1000
- 入力される数値はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
H W N
出力
H 行出力せよ。i 行目には長さ W の文字列であって、(i, j) が白で塗られている場合は j 文字目が .、黒で塗られている場合は j 文字目が # であるものを出力せよ。
入力例 1
3 4 5
出力例 1
.#.. ##.. ....
グリッドの各マスは操作によって以下のように変化します。
.... #... ##.. ##.. ##.. .#.. .... → .... → .... → .#.. → ##.. → ##.. .... .... .... .... .... ....
入力例 2
2 2 1000
出力例 2
.. ..
入力例 3
10 10 10
出力例 3
##........ ##........ .......... .......... .......... .......... .......... .......... .......... #........#
Score: 250 points
Problem Statement
There is a grid with H rows and W columns; initially, all cells are painted white. Let (i, j) denote the cell at the i-th row from the top and the j-th column from the left.
This grid is considered to be toroidal. That is, (i, 1) is to the right of (i, W) for each 1 \leq i \leq H, and (1, j) is below (H, j) for each 1 \leq j \leq W.
Takahashi is at (1, 1) and facing upwards. Print the color of each cell in the grid after Takahashi repeats the following operation N times.
- If the current cell is painted white, repaint it black, rotate 90^\circ clockwise, and move forward one cell in the direction he is facing. Otherwise, repaint the current cell white, rotate 90^\circ counterclockwise, and move forward one cell in the direction he is facing.
Constraints
- 1 \leq H, W \leq 100
- 1 \leq N \leq 1000
- All input values are integers.
Input
The input is given from Standard Input in the following format:
H W N
Output
Print H lines. The i-th line should contain a string of length W where the j-th character is . if the cell (i, j) is painted white, and # if it is painted black.
Sample Input 1
3 4 5
Sample Output 1
.#.. ##.. ....
The cells of the grid change as follows due to the operations:
.... #... ##.. ##.. ##.. .#.. .... → .... → .... → .#.. → ##.. → ##.. .... .... .... .... .... ....
Sample Input 2
2 2 1000
Sample Output 2
.. ..
Sample Input 3
10 10 10
Sample Output 3
##........ ##........ .......... .......... .......... .......... .......... .......... .......... #........#
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
AtCoder 市では、N 種類のゴミを定期的に収集しています。i\;(=1,2,\dots,N) 種類目のゴミは、日付を q_i で割ったあまりが r_i の日に収集されます。
Q 個の質問に答えてください。j\;(=1,2,\dots,Q) 番目の質問では、d_j 日に t_j 種類目のゴミが出たときに、次にそれが収集される日を答えてください。
ただし、i 種類目のゴミが出た日が、 i 種類目のゴミが回収される日であった場合、そのゴミは同じ日に収集されるとします。
制約
- 1 \leq N \leq 100
- 0 \leq r_i < q_i \leq 10^9
- 1 \leq Q \leq 100
- 1 \leq t_j \leq N
- 1 \leq d_j \leq 10^9
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N q_1 r_1 q_2 r_2 \vdots q_N r_N Q t_1 d_1 t_2 d_2 \vdots t_Q d_Q
出力
Q 行出力せよ。j\;(1\leq j \leq Q) 行目には、j 番目の質問に対する答えを出力せよ。
入力例 1
2 7 3 4 2 5 1 1 1 3 1 4 1 15 2 7
出力例 1
3 3 10 17 10
- 1 番目の質問:1 種類目のゴミが 1 日以降に初めて回収されるのは 3 日です。
- 2 番目の質問:1 種類目のゴミが 3 日以降に初めて回収されるのは 3 日です。
- 3 番目の質問:1 種類目のゴミが 4 日以降に初めて回収されるのは 10 日です。
Score : 200 points
Problem Statement
In AtCoder City, N types of garbage are collected regularly. The i-th type of garbage (i=1,2,\dots,N) is collected on days when the date modulo q_i equals r_i.
Answer Q queries. In the j-th query (j=1,2,\dots,Q), given that the t_j-th type of garbage is put out on day d_j, answer the next day on which it will be collected.
Here, if the i-th type of garbage is put out on a day when that type of garbage is collected, then the garbage will be collected on the same day.
Constraints
- 1 \leq N \leq 100
- 0 \leq r_i < q_i \leq 10^9
- 1 \leq Q \leq 100
- 1 \leq t_j \leq N
- 1 \leq d_j \leq 10^9
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N q_1 r_1 q_2 r_2 \vdots q_N r_N Q t_1 d_1 t_2 d_2 \vdots t_Q d_Q
Output
Print Q lines. The j-th line (1\leq j \leq Q) should contain the answer to the j-th query.
Sample Input 1
2 7 3 4 2 5 1 1 1 3 1 4 1 15 2 7
Sample Output 1
3 3 10 17 10
- 1st query: The 1st type of garbage is collected on day 3 for the first time after day 1.
- 2nd query: The 1st type of garbage is collected on day 3 for the first time after day 3.
- 3rd query: The 1st type of garbage is collected on day 10 for the first time after day 4.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 350 点
問題文
正の整数 X は、次の条件をみたすときかつその時に限り、良い整数と呼ばれます。
- 正の整数の組 (a,b) を用いて、X=2^a\times b^2 と書ける。
例えば、400 は 400=2^2\times 10^2 と書けるため、良い整数です。
正の整数 N が与えられるので、1 以上 N 以下の良い整数の個数を求めてください。
制約
- 1 \leq N \leq 10^{18}
- N は整数
入力
入力は以下の形式で標準入力から与えられる。
N
出力
1 以上 N 以下の良い整数の個数を出力せよ。
入力例 1
20
出力例 1
5
1 以上 20 以下の良い整数は 2,4,8,16,18 の 5 つです。
よって、5 を出力します。
入力例 2
400
出力例 2
24
入力例 3
1234567890
出力例 3
42413
入力が 32bit 整数型に収まるとは限らないことに注意してください。
Score : 350 points
Problem Statement
A positive integer X is called a good integer if and only if it satisfies the following condition:
- There exists a pair of positive integers (a,b) such that X = 2^a \times b^2.
For example, 400 is a good integer because 400 = 2^2 \times 10^2.
Given a positive integer N, find the number of good integers between 1 and N, inclusive.
Constraints
- 1 \leq N \leq 10^{18}
- N is an integer.
Input
The input is given from Standard Input in the following format:
N
Output
Print the number of good integers between 1 and N, inclusive.
Sample Input 1
20
Sample Output 1
5
There are five good integers between 1 and 20: 2, 4, 8, 16, and 18.
Thus, print 5.
Sample Input 2
400
Sample Output 2
24
Sample Input 3
1234567890
Sample Output 3
42413
Note that the input might not fit in a 32-bit integer type.