Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
円周率の小数第 100 位までの値は
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
です。
1 以上 100 以下の整数 N が与えられます。
円周率を小数第 N 位まで出力してください。
より厳密には、円周率を小数第 N+1 位で切り捨て、末尾の 0 を取り除かずに出力してください。
制約
- 1\leq N\leq 100
- N は整数
入力
入力は以下の形式で標準入力から与えられる。
N
出力
円周率を小数第 N 位まで 1 行で出力せよ。
入力例 1
2
出力例 1
3.14
円周率を小数第 2+1 位で切り捨てると値は 3.14 になります。
よって、3.14 を出力してください。
入力例 2
32
出力例 2
3.14159265358979323846264338327950
末尾の 0 は取り除かずに出力してください。
入力例 3
100
出力例 3
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
Score : 100 points
Problem Statement
The number pi to the 100-th decimal place is
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679.
You are given an integer N between 1 and 100, inclusive.
Print the value of pi to the N-th decimal place.
More precisely, truncate the value of pi to N decimal places and print the result without removing the trailing 0s.
Constraints
- 1\leq N\leq 100
- N is an integer.
Input
The input is given from Standard Input in the following format:
N
Output
Print the value of pi to the N-th decimal place in a single line.
Sample Input 1
2
Sample Output 1
3.14
Truncating the value of pi to 2 decimal places results in 3.14. Thus, you should print 3.14.
Sample Input 2
32
Sample Output 2
3.14159265358979323846264338327950
Do not remove the trailing 0s.
Sample Input 3
100
Sample Output 3
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
英小文字と . のみからなる文字列 S が与えられます。
S を . で分割したときの末尾の文字列を出力してください。
すなわち、. を含まない S の接尾辞のうち最長のものを出力してください。
制約
- S は英小文字と
.からなる、長さ 2 以上 100 以下の文字列 - S には
.が 1 つ以上含まれる - S の末尾は
.ではない
入力
入力は以下の形式で標準入力から与えられる。
S
出力
答えを出力せよ。
入力例 1
atcoder.jp
出力例 1
jp
atcoder.jp の、 . を含まない最長の接尾辞は jp です。
入力例 2
translate.google.com
出力例 2
com
S に . が複数含まれることもあります。
入力例 3
.z
出力例 3
z
S が . から始まることもあります。
入力例 4
..........txt
出力例 4
txt
S 中で . が連続することもあります。
Score: 100 points
Problem Statement
You are given a string S consisting of lowercase English letters and the character ..
Print the last substring when S is split by .s.
In other words, print the longest suffix of S that does not contain ..
Constraints
- S is a string of length between 2 and 100, inclusive, consisting of lowercase English letters and
.. - S contains at least one
.. - S does not end with
..
Input
The input is given from Standard Input in the following format:
S
Output
Print the answer.
Sample Input 1
atcoder.jp
Sample Output 1
jp
The longest suffix of atcoder.jp that does not contain . is jp.
Sample Input 2
translate.google.com
Sample Output 2
com
S may contain multiple .s.
Sample Input 3
.z
Sample Output 3
z
S may start with ..
Sample Input 4
..........txt
Sample Output 4
txt
S may contain consecutive .s.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
英小文字からなる文字列 S と T が与えられます。
以下の条件を満たす 1 \leq c \leq w < |S| となる整数の組 c と w が存在するか判定してください。ただし、 |S| は文字列 S の長さを表します。ここで、w は |S| 未満である必要があることに注意してください。
- S を先頭から順に w 文字毎に区切ったとき、長さが c 以上の文字列の c 文字目を順番に連結した文字列が T と一致する
制約
- S と T は英小文字からなる文字列
- 1 \leq |T| \leq |S| \leq 100
入力
入力は以下の形式で標準入力から与えられる。
S T
出力
条件を満たすような 1 \leq c \leq w < |S| となる整数の組 c と w が存在する場合は Yes を、存在しない場合は No を出力せよ。
入力例 1
atcoder toe
出力例 1
Yes
S を 2 文字毎に区切ると以下のようになります。
at co de r
区切った後、 2 文字以上の文字列の 2 文字目を取り出し連結させたときの文字列は、 toe となり T と一致します。よって、 Yes を出力します。
入力例 2
beginner r
出力例 2
No
w=|S| であることはないため、条件を満たすような 1 \leq c \leq w < |S| となる整数の組 c と w は存在しません。よって、 No を出力します。
入力例 3
verticalreading agh
出力例 3
No
Score : 200 points
Problem Statement
You are given two strings S and T consisting of lowercase English letters.
Determine if there exists a pair of integers c and w such that 1 \leq c \leq w < |S| and the following condition is satisfied. Here, |S| denotes the length of the string S. Note that w must be less than |S|.
- If S is split at every w characters from the beginning, the concatenation of the c-th characters of the substrings of length at least c in order equals T.
Constraints
- S and T are strings consisting of lowercase English letters.
- 1 \leq |T| \leq |S| \leq 100
Input
The input is given from Standard Input in the following format:
S T
Output
Print Yes if there exists a pair of integers c and w such that 1 \leq c \leq w < |S| and the condition is satisfied, and No otherwise.
Sample Input 1
atcoder toe
Sample Output 1
Yes
If S is split at every two characters, it looks like this:
at co de r
Then, the concatenation of the 2nd characters of the substrings of length at least 2 is toe, which equals T. Thus, print Yes.
Sample Input 2
beginner r
Sample Output 2
No
w=|S| is not allowed, and no pair of integers 1 \leq c \leq w < |S| satisfies the condition. Thus, print No.
Sample Input 3
verticalreading agh
Sample Output 3
No
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 250 点
問題文
縦 H マス \times 横 W マスのマス目があり、各マスに 1 つずつ英小文字が書き込まれています。 上から i 行目かつ左から j 列目のマスを (i,j) で表します。
マス目に書き込まれている英小文字は H 個の長さ W の文字列 S_1,S_2,\ldots, S_H によって与えられ、 S_i の j 文字目が、(i, j) に書き込まれた英小文字を表します。
マス目の中に、s, n, u, k, e が
この順に(縦・横・ななめのいずれかの方向に) 連続して並んでいる
場所がただ 1 つ存在します。
そのような場所を見つけ、そのマスの位置を出力の形式に従って出力してください。
ただし、s, n, u, k, e が
この順に(縦・横・ななめのいずれかの方向に) 連続して並んでいる場所とは、
5 つのマスの組 (A_1,A_2,A_3,A_4,A_5) であって、次をすべてみたすものをさします。
- A_1,A_2,A_3,A_4,A_5 に書き込まれた英小文字はそれぞれ
s,n,u,k,eである。 - 1\leq i\leq 4 について、A_i と A_{i+1} は頂点または辺を共有している。
- A_1,A_2,A_3,A_4,A_5 の中心はこの順に一直線上に等間隔で並んでいる。
制約
- 5\leq H\leq 100
- 5\leq W\leq 100
- H,W は整数
- S_i は英小文字のみからなる長さ W の文字列
- 与えられるマス目の中に条件をみたす場所がただ 1 つ存在する
入力
入力は以下の形式で標準入力から与えられる。
H W S_1 S_2 \vdots S_H
出力
次の形式にしたがって、5 行出力せよ。
条件をみたす場所のうち s, n, u, k, e が書かれたマスがそれぞれ (R_1,C_1), (R_2,C_2)\ldots,(R_5,C_5) であるとき、
i 行目には R_i と C_i をこの順に空白区切りで出力せよ。
すなわち、以下のように出力せよ。
R_1 C_1 R_2 C_2 \vdots R_5 C_5
以下の入力例も参考にせよ。
入力例 1
6 6 vgxgpu amkxks zhkbpp hykink esnuke zplvfj
出力例 1
5 2 5 3 5 4 5 5 5 6
この時、(A_1,A_2,A_3,A_4,A_5)=((5,2),(5,3),(5,4),(5,5),(5,6)) とすると、
それぞれのマスに書き込まれた英小文字は s, n, u, k, e であり、
1\leq i\leq 4 について、A_i と A_{i+1} は辺を共有しており、
各マスの中心は一直線上に存在するため、条件をみたしています。

入力例 2
5 5 ezzzz zkzzz ezuzs zzznz zzzzs
出力例 2
5 5 4 4 3 3 2 2 1 1
(A_1,A_2,A_3,A_4,A_5)=((5,5),(4,4),(3,3),(2,2),(1,1)) が条件をみたしています。
例えば、(A_1,A_2,A_3,A_4,A_5)=((3,5),(4,4),(3,3),(2,2),(3,1)) は、1,2 つめの条件をみたしていますが、
マスの中心が一直線上に存在しないため、3 つめの条件をみたしていません。
入力例 3
10 10 kseeusenuk usesenesnn kskekeeses nesnusnkkn snenuuenke kukknkeuss neunnennue sknuessuku nksneekknk neeeuknenk
出力例 3
9 3 8 3 7 3 6 3 5 3
Score : 250 points
Problem Statement
There is a grid with H horizontal rows and W vertical columns. Each cell has a lowercase English letter written on it. We denote by (i, j) the cell at the i-th row from the top and j-th column from the left.
The letters written on the grid are represented by H strings S_1,S_2,\ldots, S_H, each of length W. The j-th letter of S_i represents the letter written on (i, j).
There is a unique set of
contiguous cells (going vertically, horizontally, or diagonally) in the grid
with s, n, u, k, and e written on them in this order.
Find the positions of such cells and print them in the format specified in the Output section.
A tuple of five cells (A_1,A_2,A_3,A_4,A_5) is said to form
a set of contiguous cells (going vertically, horizontally, or diagonally) with s, n, u, k, and e written on them in this order
if and only if all of the following conditions are satisfied.
- A_1,A_2,A_3,A_4 and A_5 have letters
s,n,u,k, andewritten on them, respectively. - For all 1\leq i\leq 4, cells A_i and A_{i+1} share a corner or a side.
- The centers of A_1,A_2,A_3,A_4, and A_5 are on a common line at regular intervals.
Constraints
- 5\leq H\leq 100
- 5\leq W\leq 100
- H and W are integers.
- S_i is a string of length W consisting of lowercase English letters.
- The given grid has a unique conforming set of cells.
Input
The input is given from Standard Input in the following format:
H W S_1 S_2 \vdots S_H
Output
Print five lines in the following format.
Let (R_1,C_1), (R_2,C_2)\ldots,(R_5,C_5) be the cells in the sought set with s, n, u, k, and e written on them, respectively.
The i-th line should contain R_i and C_i in this order, separated by a space.
In other words, print them in the following format:
R_1 C_1 R_2 C_2 \vdots R_5 C_5
See also Sample Inputs and Outputs below.
Sample Input 1
6 6 vgxgpu amkxks zhkbpp hykink esnuke zplvfj
Sample Output 1
5 2 5 3 5 4 5 5 5 6
Tuple (A_1,A_2,A_3,A_4,A_5)=((5,2),(5,3),(5,4),(5,5),(5,6)) satisfies the conditions.
Indeed, the letters written on them are s, n, u, k, and e;
for all 1\leq i\leq 4, cells A_i and A_{i+1} share a side;
and the centers of the cells are on a common line.

Sample Input 2
5 5 ezzzz zkzzz ezuzs zzznz zzzzs
Sample Output 2
5 5 4 4 3 3 2 2 1 1
Tuple (A_1,A_2,A_3,A_4,A_5)=((5,5),(4,4),(3,3),(2,2),(1,1)) satisfies the conditions.
However, for example, (A_1,A_2,A_3,A_4,A_5)=((3,5),(4,4),(3,3),(2,2),(3,1)) violates the third condition because the centers of the cells are not on a common line, although it satisfies the first and second conditions.
Sample Input 3
10 10 kseeusenuk usesenesnn kskekeeses nesnusnkkn snenuuenke kukknkeuss neunnennue sknuessuku nksneekknk neeeuknenk
Sample Output 3
9 3 8 3 7 3 6 3 5 3
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 300 点
問題文
高橋君は数直線上の座標 0 の位置にいます。
これから高橋君は N 回のジャンプを行います。i \, (1 \leq i \leq N) 回目のジャンプでは、正の方向に a_i または b_i 移動します。
N 回のジャンプの後に座標 X の位置にいるようにすることはできますか?
制約
- 1 \leq N \leq 100
- 1 \leq a_i \lt b_i \leq 100 \, (1 \leq i \leq N)
- 1 \leq X \leq 10000
- 入力は全て整数
入力
入力は以下の形式で標準入力から与えられる。
N X a_1 b_1 \vdots a_N b_N
出力
N 回のジャンプの後に座標 X の位置にいるようにすることができるならば Yes と、そうでないなら No と出力せよ。
入力例 1
2 10 3 6 4 5
出力例 1
Yes
1 回目のジャンプでは b_1 (= 6) 移動し、2 回目のジャンプでは a_2 (= 4) 移動することで、座標 X (= 10) の位置にいるようにすることができます。
入力例 2
2 10 10 100 10 100
出力例 2
No
1 回目のジャンプの後に座標 X (= 10) の位置にいるようにすることはできますが、全てのジャンプの後に座標 X (= 10) の位置にいるようにすることはできません。
入力例 3
4 12 1 8 5 7 3 4 2 6
出力例 3
Yes
Score : 300 points
Problem Statement
Takahashi is standing at the coordinate 0 on a number line.
He will now perform N jumps. In the i-th jump (1 \leq i \leq N), he moves a_i or b_i in the positive direction.
Is it possible for him to be at the coordinate X after N jumps?
Constraints
- 1 \leq N \leq 100
- 1 \leq a_i \lt b_i \leq 100 \, (1 \leq i \leq N)
- 1 \leq X \leq 10000
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
N X a_1 b_1 \vdots a_N b_N
Output
If it is possible for Takahashi to be at the coordinate X after N jumps, print Yes; otherwise, print No.
Sample Input 1
2 10 3 6 4 5
Sample Output 1
Yes
By moving b_1 (= 6) in the first jump and a_2 (= 4) in the second jump, he can be at the coordinate X (= 10).
Sample Input 2
2 10 10 100 10 100
Sample Output 2
No
He can be at the coordinate X (= 10) after the first jump, but not after all jumps.
Sample Input 3
4 12 1 8 5 7 3 4 2 6
Sample Output 3
Yes