Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
高橋君は N 個の料理を食べようとしています。
i 番目に食べようとしている料理は、S_i = sweet のとき甘い料理であり、S_i = salty のとき塩辛い料理です。
高橋君は甘い料理を 2 つ連続で食べると気持ち悪くなってしまい、その後料理が食べられなくなってしまいます。
高橋君がすべての料理を食べることができるか判定してください。
制約
- N は 1 以上 100 以下の整数
- S_i は
sweetまたはsalty
入力
入力は以下の形式で標準入力から与えられる。
N S_1 S_2 \vdots S_N
出力
高橋君がすべての料理を食べることができるならば Yes を、できないならば No を出力せよ。
入力例 1
5 salty sweet salty salty sweet
出力例 1
Yes
高橋君は甘い料理を 2 つ連続で食べることがないので、気持ち悪くなることなくすべての料理を食べることができます。
入力例 2
4 sweet salty sweet sweet
出力例 2
Yes
高橋君は気持ち悪くなってしまいますが、すべての料理を食べることができます。
入力例 3
6 salty sweet sweet salty sweet sweet
出力例 3
No
高橋君は 3 番目の料理を食べると気持ち悪くなってしまい、4 番目以降の料理が食べられなくなります。
Score : 100 points
Problem Statement
Takahashi is planning to eat N dishes.
The i-th dish he plans to eat is sweet if S_i = sweet, and salty if S_i = salty.
If he eats two sweet dishes consecutively, he will feel sick and be unable to eat any more dishes.
Determine whether he can eat all the dishes.
Constraints
- N is an integer between 1 and 100, inclusive.
- Each S_i is
sweetorsalty.
Input
The input is given from Standard Input in the following format:
N S_1 S_2 \vdots S_N
Output
Print Yes if Takahashi can eat all the dishes, and No otherwise.
Sample Input 1
5 salty sweet salty salty sweet
Sample Output 1
Yes
He will not eat two sweet dishes consecutively, so he can eat all the dishes without feeling sick.
Sample Input 2
4 sweet salty sweet sweet
Sample Output 2
Yes
He will feel sick but can still eat all the dishes.
Sample Input 3
6 salty sweet sweet salty sweet sweet
Sample Output 3
No
He feels sick when eating the 3rd dish and cannot eat the 4th and subsequent dishes.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
キーエンスでは、役割や年齢、立場の違いに関係なく「さん」付けして呼ぶという文化があります。
英小文字のみからなる文字列 S が与えられます。
S が san で終わっているならば Yes を、終わっていないならば No を出力してください。
制約
- S は英小文字のみからなる長さ 4 以上 30 以下の文字列
入力
入力は以下の形式で標準入力から与えられる。
S
出力
S が san で終わっているならば Yes を、終わっていないならば No を出力せよ。
入力例 1
takahashisan
出力例 1
Yes
文字列 S=takahashisan は san で終わっているため、 Yes を出力します。
入力例 2
aokikun
出力例 2
No
文字列 S=aokikun は san で終わっていないため、 No を出力します。
Score : 100 points
Problem Statement
KEYENCE has a culture of addressing everyone with the suffix "-san," regardless of roles, age, or positions.
You are given a string S consisting of lowercase English letters.
If S ends with san, print Yes; otherwise, print No.
Constraints
- S is a string of length between 4 and 30, inclusive, consisting of lowercase English letters.
Input
The input is given from Standard Input in the following format:
S
Output
If S ends with san, print Yes; otherwise, print No.
Sample Input 1
takahashisan
Sample Output 1
Yes
The string S= takahashisan ends with san, so print Yes.
Sample Input 2
aokikun
Sample Output 2
No
The string S= aokikun does not end with san, so print No.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
正整数 x に対して、f(x) を x の十進表記における各桁の和として定義します。例えば、f(123) = 1 + 2 + 3 = 6 です。
無限数列 A = (A_0, A_1, A_2, \ldots) を以下の式により定義します。
- A_0 = 1
- i \geq 1 のとき A_i = \displaystyle\sum_{j = 0}^{i - 1} f(A_j)
正整数 N が与えられます。A_N の値を求めてください。
制約
- N は 1 以上 100 以下の整数
入力
入力は以下の形式で標準入力から与えられる。
N
出力
答えを出力せよ。
入力例 1
6
出力例 1
23
- A_0 = 1
- A_1 = f(A_0) = 1
- A_2 = f(A_0) + f(A_1) = 2
- A_3 = f(A_0) + f(A_1) + f(A_2) = 4
- A_4 = f(A_0) + f(A_1) + f(A_2) + f(A_3) = 8
- A_5 = f(A_0) + f(A_1) + f(A_2) + f(A_3) + f(A_4) = 16
- A_6 = f(A_0) + f(A_1) + f(A_2) + f(A_3) + f(A_4) + f(A_5) = 23
であるため、A_6 = 23 です。
入力例 2
45
出力例 2
427
Score : 200 points
Problem Statement
For a positive integer x, define f(x) as the sum of the digits in the decimal representation of x. For example, f(123) = 1 + 2 + 3 = 6.
Define an infinite sequence A = (A_0, A_1, A_2, \ldots) by the following formula:
- A_0 = 1
- For i \geq 1, A_i = \displaystyle\sum_{j = 0}^{i - 1} f(A_j)
You are given a positive integer N. Find the value of A_N.
Constraints
- N is an integer between 1 and 100, inclusive.
Input
The input is given from Standard Input in the following format:
N
Output
Print the answer.
Sample Input 1
6
Sample Output 1
23
- A_0 = 1
- A_1 = f(A_0) = 1
- A_2 = f(A_0) + f(A_1) = 2
- A_3 = f(A_0) + f(A_1) + f(A_2) = 4
- A_4 = f(A_0) + f(A_1) + f(A_2) + f(A_3) = 8
- A_5 = f(A_0) + f(A_1) + f(A_2) + f(A_3) + f(A_4) = 16
- A_6 = f(A_0) + f(A_1) + f(A_2) + f(A_3) + f(A_4) + f(A_5) = 23
Thus, A_6 = 23.
Sample Input 2
45
Sample Output 2
427
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
-10^{18} 以上 10^{18} 以下の整数 X が与えられるので、\left\lceil \dfrac{X}{10} \right\rceil を出力してください。
ここで、\left\lceil a \right\rceil は a 以上の整数のうち最小のものを意味します。
制約
- -10^{18} \leq X \leq 10^{18}
- X は整数
入力
入力は以下の形式で標準入力から与えられる。
X
出力
\left\lceil \dfrac{X}{10} \right\rceil を整数として出力せよ。
入力例 1
27
出力例 1
3
\frac{27}{10} = 2.7 以上の整数は 3, 4, 5, \dots です。この中で一番小さい整数は 3 なので、\left \lceil \frac{27}{10} \right \rceil = 3 となります。
入力例 2
-13
出力例 2
-1
\frac{-13}{10} = -1.3 以上の整数は、全ての正整数および 0, -1 です。この中で一番小さい整数は -1 なので、\left \lceil \frac{-13}{10} \right \rceil = -1 となります。
入力例 3
40
出力例 3
4
\frac{40}{10} = 4 以上の整数で一番小さい整数は 4 自身です。
入力例 4
-20
出力例 4
-2
入力例 5
123456789123456789
出力例 5
12345678912345679
Score: 200 points
Problem Statement
Given an integer X between -10^{18} and 10^{18}, inclusive, print \left\lceil \dfrac{X}{10} \right\rceil.
Here, \left\lceil a \right\rceil denotes the smallest integer not less than a.
Constraints
- -10^{18} \leq X \leq 10^{18}
- X is an integer.
Input
The input is given from Standard Input in the following format:
X
Output
Print \left\lceil \dfrac{X}{10} \right\rceil as an integer.
Sample Input 1
27
Sample Output 1
3
The integers not less than \frac{27}{10} = 2.7 are 3, 4, 5, \dots. Among these, the smallest is 3, so \left \lceil \frac{27}{10} \right \rceil = 3.
Sample Input 2
-13
Sample Output 2
-1
The integers not less than \frac{-13}{10} = -1.3 are all positive integers, 0, and -1. Among these, the smallest is -1, so \left \lceil \frac{-13}{10} \right \rceil = -1.
Sample Input 3
40
Sample Output 3
4
The smallest integer not less than \frac{40}{10} = 4 is 4 itself.
Sample Input 4
-20
Sample Output 4
-2
Sample Input 5
123456789123456789
Sample Output 5
12345678912345679
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 250 点
問題文
9\times 9 のマス目 A があり、各マスには 1 以上 9 以下の整数が書き込まれています。
具体的には、 A の上から i 行目、左から j 列目のマスには A_{i,j} が書き込まれています。
A が次の条件をすべてみたしているならば Yes を、そうでないならば No を出力してください。
- A の各行について、その行に含まれる 9 マスには 1 以上 9 以下の整数がちょうど 1 個ずつ書き込まれている。
- A の各列について、その列に含まれる 9 マスには 1 以上 9 以下の整数がちょうど 1 個ずつ書き込まれている。
- A の行を上から 3 行ずつ 3 つに分け、同様に列も左から 3 列ずつ 3 つに分ける。 これによって A を 9 つの 3\times 3 のマス目に分けたとき、それぞれの 3\times 3 のマス目には 1 以上 9 以下の整数がちょうど 1 個ずつ書き込まれている。
制約
- 1\leq A_{i,j}\leq 9
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
A_{1,1} A_{1,2} \ldots A_{1,9}
A_{2,1} A_{2,2} \ldots A_{2,9}
\vdots
A_{9,1} A_{9,2} \ldots A_{9,9}
出力
マス目 A が問題文の条件をすべてみたすならば Yes を、
そうでないならば No を出力せよ。
入力例 1
1 2 3 4 5 6 7 8 9 4 5 6 7 8 9 1 2 3 7 8 9 1 2 3 4 5 6 2 3 4 5 6 7 8 9 1 5 6 7 8 9 1 2 3 4 8 9 1 2 3 4 5 6 7 3 4 5 6 7 8 9 1 2 6 7 8 9 1 2 3 4 5 9 1 2 3 4 5 6 7 8
出力例 1
Yes
マス目 A は次のようになっています。

マス目 A は 3 つの条件をすべてみたしているため、Yes を出力します。
入力例 2
1 2 3 4 5 6 7 8 9 2 3 4 5 6 7 8 9 1 3 4 5 6 7 8 9 1 2 4 5 6 7 8 9 1 2 3 5 6 7 8 9 1 2 3 4 6 7 8 9 1 2 3 4 5 7 8 9 1 2 3 4 5 6 8 9 1 2 3 4 5 6 7 9 1 2 3 4 5 6 7 8
出力例 2
No
マス目 A は次のようになっています。

例えば左上の 3\times 3 のマス目に注目すると 3 つめの条件をみたしていないことが分かるため、No を出力します。
入力例 3
1 2 3 4 5 6 7 8 9 4 5 6 7 8 9 1 2 3 7 8 9 1 2 3 4 5 6 1 2 3 4 5 6 7 8 9 4 5 6 7 8 9 1 2 3 7 8 9 1 2 3 4 5 6 1 2 3 4 5 6 7 8 9 4 5 6 7 8 9 1 2 3 7 8 9 1 2 3 4 5 6
出力例 3
No
マス目 A は次のようになっています。

例えば一番左の列に注目すると 2 つめの条件をみたしていないことが分かるため、No を出力します。
Score : 250 points
Problem Statement
There is a 9\times 9 grid A, where each cell contains an integer between 1 and 9, inclusive.
Specifically, the cell at the i-th row from the top and j-th column from the left contains A_{i,j}.
If A satisfies all of the following conditions, print Yes. Otherwise, print No.
- For each row of A, the nine cells in that row contain each integer from 1 to 9 exactly once.
- For each column of A, the nine cells in that column contain each integer from 1 to 9 exactly once.
- Divide the rows of A into three groups, each of three rows, from top to bottom, and similarly divide the columns into three groups, each of three columns, from left to right. Each 3\times 3 grid obtained from A in this way contains each integer from 1 to 9 exactly once.
Constraints
- 1\leq A_{i,j}\leq 9
- All input values are integers.
Input
The input is given from Standard Input in the following format:
A_{1,1} A_{1,2} \ldots A_{1,9}
A_{2,1} A_{2,2} \ldots A_{2,9}
\vdots
A_{9,1} A_{9,2} \ldots A_{9,9}
Output
If the grid A satisfies all the conditions in the problem statement, print Yes; otherwise, print No.
Sample Input 1
1 2 3 4 5 6 7 8 9 4 5 6 7 8 9 1 2 3 7 8 9 1 2 3 4 5 6 2 3 4 5 6 7 8 9 1 5 6 7 8 9 1 2 3 4 8 9 1 2 3 4 5 6 7 3 4 5 6 7 8 9 1 2 6 7 8 9 1 2 3 4 5 9 1 2 3 4 5 6 7 8
Sample Output 1
Yes
The grid A is shown below.

The grid A satisfies all three conditions, so print Yes.
Sample Input 2
1 2 3 4 5 6 7 8 9 2 3 4 5 6 7 8 9 1 3 4 5 6 7 8 9 1 2 4 5 6 7 8 9 1 2 3 5 6 7 8 9 1 2 3 4 6 7 8 9 1 2 3 4 5 7 8 9 1 2 3 4 5 6 8 9 1 2 3 4 5 6 7 9 1 2 3 4 5 6 7 8
Sample Output 2
No
The grid A is shown below.

For example, if you look at the top left 3\times 3 grid, you can see that the third condition is unsatisfied, so print No.
Sample Input 3
1 2 3 4 5 6 7 8 9 4 5 6 7 8 9 1 2 3 7 8 9 1 2 3 4 5 6 1 2 3 4 5 6 7 8 9 4 5 6 7 8 9 1 2 3 7 8 9 1 2 3 4 5 6 1 2 3 4 5 6 7 8 9 4 5 6 7 8 9 1 2 3 7 8 9 1 2 3 4 5 6
Sample Output 3
No
The grid A is shown below.

For example, if you look at the leftmost column, you can see that the second condition is unsatisfied, so print No.