Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
高橋君はたこ焼きを作ってすぬけ君に振る舞うことにしました。高橋君はすぬけ君に、たこ焼きを食べたいならば左手のみを挙げて、そうでないならば右手のみを挙げるよう指示しました。
すぬけ君が挙げた手の情報は整数 L, R によって与えられます。 すぬけ君は L = 1 のとき、またそのときに限り左手を挙げており、R = 1 のとき、またそのときに限り右手を挙げています。すぬけ君は指示に従わず、両手を挙げることも手を挙げないこともあります。
すぬけ君が片方の手のみを挙げている場合、すぬけ君がたこ焼きを食べたいならば Yes
を、そうでないならば No
を出力してください。すぬけ君が両手を挙げているか、手を挙げていないときは Invalid
と出力してください。
ただし、すぬけ君が片方の手のみを挙げている場合は必ず指示に従った行動を取っているものとします。
制約
- L, R は 0 または 1
入力
入力は以下の形式で標準入力から与えられる。
L R
出力
問題文の指示に従って Yes
, No
, Invalid
のいずれかを出力せよ。
入力例 1
1 0
出力例 1
Yes
すぬけ君はたこ焼きを食べたいので左手のみを挙げています。
入力例 2
1 1
出力例 2
Invalid
すぬけ君は両手を挙げています。
Score : 100 points
Problem Statement
Takahashi decided to make takoyaki (octopus balls) and serve it to Snuke. Takahashi instructed Snuke to raise only his left hand if he wants to eat takoyaki, and only his right hand otherwise.
You are given the information about which hand Snuke is raising as two integers L and R. He is raising his left hand if and only if L = 1, and raising his right hand if and only if R = 1. He might not follow the instructions and could raise both hands or not raise any hand at all.
If Snuke is raising only one hand, print Yes
if he wants to eat takoyaki, and No
if he does not. If he is raising both hands or not raising any hand, print Invalid
.
Assume that if Snuke is raising only one hand, he is always following the instructions.
Constraints
- Each of L and R is 0 or 1.
Input
The input is given from Standard Input in the following format:
L R
Output
Print Yes
, No
, or Invalid
according to the instructions in the problem statement.
Sample Input 1
1 0
Sample Output 1
Yes
Snuke wants to eat takoyaki, so he is raising only his left hand.
Sample Input 2
1 1
Sample Output 2
Invalid
Snuke is raising both hands.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
N 種類の元素があり、元素には 1, 2, \ldots, N の番号が付けられています。
元素どうしは合成させることができ、元素 i と元素 j を合成すると i \geq j のとき元素 A_{i, j} に、i < j のとき元素 A_{j, i} に変化します。
元素 1 に対して元素 1, 2, \ldots, N をこの順に合成したとき、最終的に得られる元素を求めてください。
制約
- 1 \leq N \leq 100
- 1 \leq A_{i, j} \leq N
- 入力される値はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N A_{1, 1} A_{2, 1} A_{2, 2} \vdots A_{N, 1} A_{N, 2} \ldots A_{N, N}
出力
最終的に得られる元素の番号を出力せよ。
入力例 1
4 3 2 4 3 1 2 2 1 2 4
出力例 1
2
-
元素 1 と元素 1 を合成すると、元素 3 が得られます。
-
元素 3 と元素 2 を合成すると、元素 1 が得られます。
-
元素 1 と元素 3 を合成すると、元素 3 が得られます。
-
元素 3 と元素 4 を合成すると、元素 2 が得られます。
したがって、出力するべき値は 2 です。
入力例 2
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
出力例 2
5
入力例 3
6 2 1 5 1 6 3 2 6 1 4 2 1 1 1 6 5 6 1 2 2 5
出力例 3
5
Score : 200 points
Problem Statement
There are N types of elements numbered 1, 2, \ldots, N.
Elements can be combined with each other. When elements i and j are combined, they transform into element A_{i, j} if i \geq j, and into element A_{j, i} if i < j.
Starting with element 1, combine it with elements 1, 2, \ldots, N in this order. Find the final element obtained.
Constraints
- 1 \leq N \leq 100
- 1 \leq A_{i, j} \leq N
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N A_{1, 1} A_{2, 1} A_{2, 2} \vdots A_{N, 1} A_{N, 2} \ldots A_{N, N}
Output
Print the number representing the final element obtained.
Sample Input 1
4 3 2 4 3 1 2 2 1 2 4
Sample Output 1
2
-
Combining element 1 with element 1 results in element 3.
-
Combining element 3 with element 2 results in element 1.
-
Combining element 1 with element 3 results in element 3.
-
Combining element 3 with element 4 results in element 2.
Therefore, the value to be printed is 2.
Sample Input 2
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
Sample Output 2
5
Sample Input 3
6 2 1 5 1 6 3 2 6 1 4 2 1 1 1 6 5 6 1 2 2 5
Sample Output 3
5
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 300 点
問題文
英小文字からなる文字列 S, T が与えられます。ここで、S と T の長さは等しいです。
X を空の配列とし、以下の操作を S と T が等しくなるまで繰り返します。
- S の文字を 1 文字書き換え、X の末尾に S を追加する。
こうして得られる文字列の配列 X のうち要素数最小のものを求めてください。要素数最小のものが複数考えられる場合は、そのうち辞書順最小のものを求めてください。
文字列の配列の辞書順とは
長さ N の文字列 S = S_1 S_2 \ldots S_N が長さ N の文字列 T = T_1 T_2 \ldots T_N より辞書順で小さいとは、ある整数 1 \leq i \leq N が存在して下記の 2 つがともに成り立つことをいいます。
- S_1 S_2 \ldots S_{i-1} = T_1 T_2 \ldots T_{i-1}
- S_i が T_i よりアルファベット順で早い。
要素数 M の文字列の配列 X = (X_1,X_2,\ldots,X_M) が要素数 M の文字列の配列 Y = (Y_1,Y_2,\ldots,Y_M) より辞書順で小さいとは、ある整数 1 \leq j \leq M が存在して下記の 2 つがともに成り立つことをいいます。
- (X_1,X_2,\ldots,X_{j-1}) = (Y_1,Y_2,\ldots,Y_{j-1})
- X_j が Y_j より辞書順で小さい。
制約
- S, T は英小文字からなる長さ 1 以上 100 以下の文字列
- S と T の長さは等しい
入力
入力は以下の形式で標準入力から与えられる。
S T
出力
答えの要素数を M として M + 1 行出力せよ。
1 行目には M の値を出力せよ。
i + 1 (1 \leq i \leq M) 行目には答えの i 番目の要素を出力せよ。
入力例 1
adbe bcbc
出力例 1
3 acbe acbc bcbc
はじめ、S = adbe
です。
以下のように操作することで、X = ( acbe
, acbc
, bcbc
) とすることができます。
-
S を
acbe
に書き換え、X の末尾にacbe
を追加する。 -
S を
acbc
に書き換え、X の末尾にacbc
を追加する。 -
S を
bcbc
に書き換え、X の末尾にbcbc
を追加する。
入力例 2
abcde abcde
出力例 2
0
入力例 3
afwgebrw oarbrenq
出力例 3
8 aawgebrw aargebrw aarbebrw aarbebnw aarbebnq aarbeenq aarbrenq oarbrenq
Score : 300 points
Problem Statement
You are given two strings S and T consisting of lowercase English letters. Here, S and T have equal lengths.
Let X be an empty array, and repeat the following operation until S equals T:
- Change one character in S, and append S to the end of X.
Find the array of strings X with the minimum number of elements obtained in this way. If there are multiple such arrays with the minimum number of elements, find the lexicographically smallest one among them.
What is lexicographical order on arrays of strings?
A string S = S_1 S_2 \ldots S_N of length N is lexicographically smaller than a string T = T_1 T_2 \ldots T_N of length N if there exists an integer 1 \leq i \leq N such that both of the following are satisfied:
- S_1 S_2 \ldots S_{i-1} = T_1 T_2 \ldots T_{i-1}
- S_i comes earlier than T_i in alphabetical order.
An array of strings X = (X_1,X_2,\ldots,X_M) with M elements is lexicographically smaller than an array of strings Y = (Y_1,Y_2,\ldots,Y_M) with M elements if there exists an integer 1 \leq j \leq M such that both of the following are satisfied:
- (X_1,X_2,\ldots,X_{j-1}) = (Y_1,Y_2,\ldots,Y_{j-1})
- X_j is lexicographically smaller than Y_j.
Constraints
- S and T are strings consisting of lowercase English letters with length between 1 and 100, inclusive.
- The lengths of S and T are equal.
Input
The input is given from Standard Input in the following format:
S T
Output
Let M be the number of elements in the desired array. Print M + 1 lines.
The first line should contain the value of M.
The i + 1-th line (1 \leq i \leq M) should contain the i-th element of the array.
Sample Input 1
adbe bcbc
Sample Output 1
3 acbe acbc bcbc
Initially, S = adbe
.
We can obtain X = ( acbe
, acbc
, bcbc
) by performing the following operations:
-
Change S to
acbe
and appendacbe
to the end of X. -
Change S to
acbc
and appendacbc
to the end of X. -
Change S to
bcbc
and appendbcbc
to the end of X.
Sample Input 2
abcde abcde
Sample Output 2
0
Sample Input 3
afwgebrw oarbrenq
Sample Output 3
8 aawgebrw aargebrw aarbebrw aarbebnw aarbebnq aarbeenq aarbrenq oarbrenq
Time Limit: 4 sec / Memory Limit: 1024 MiB
配点 : 400 点
問題文
縦 H マス、横 W マスのグリッドがあります。上から i 行目、左から j 列目のマスを (i, j) と表します。
はじめ、全てのマスには壁が 1 個ずつ立てられています。
以下で説明されるクエリを Q 個与えられる順に処理した後に、残っている壁の個数を求めてください。
q 番目のクエリでは整数 R_q, C_q が与えられます。
あなたは (R_q, C_q) に爆弾を置いて壁を爆破します。その結果、以下の処理が行われます。
- (R_q, C_q) に壁が存在する場合は、その壁を破壊して処理を終了する。
- (R_q, C_q) に壁が存在しない場合は、(R_q, C_q) から上下左右に見て最初に現れる壁を破壊する。厳密に述べると、以下の 4 個の処理が同時に行われる。
- (i, C_q) に壁が存在して (k, C_q) (i \lt k \lt R_q) に壁が存在しないような i \lt R_q が存在する時、(i, C_q) に存在する壁を破壊する。
- (i, C_q) に壁が存在して (k, C_q) (R_q \lt k \lt i) に壁が存在しないような i \gt R_q が存在する時、(i, C_q) に存在する壁を破壊する。
- (R_q, j) に壁が存在して (R_q, k) (j \lt k \lt C_q) に壁が存在しないような j \lt C_q が存在する時、(R_q, j) に存在する壁を破壊する。
- (R_q, j) に壁が存在して (R_q, k) (C_q \lt k \lt j) に壁が存在しないような j \gt C_q が存在する時、(R_q, j) に存在する壁を破壊する。
制約
- 1 \leq H, W
- H \times W \leq 4 \times 10^5
- 1 \leq Q \leq 2 \times 10^5
- 1 \leq R_q \leq H
- 1 \leq C_q \leq W
- 入力される値は全て整数
入力
入力は以下の形式で標準入力から与えられる。
H W Q R_1 C_1 R_2 C_2 \vdots R_Q C_Q
出力
クエリを全て処理した後に、残っている壁の個数を出力せよ。
入力例 1
2 4 3 1 2 1 2 1 3
出力例 1
2
クエリを処理する手順を説明すると次のようになります。
- 1 番目のクエリでは (R_1, C_1) = (1, 2) である。 (1, 2) に壁は存在するので (1, 2) の壁が爆破される。
- 2 番目のクエリでは (R_2, C_2) = (1, 2) である。 (1, 2) に壁は存在しないので、(1, 2) から上下左右に見て最初に現れる壁である (2,2),(1,1),(1,3) が爆破される。
- 3 番目のクエリでは (R_2, C_2) = (1, 3) である。 (1, 3) に壁は存在しないので、(1, 3) から上下左右に見て最初に現れる壁である (2,3),(1,4) が爆破される。
全てのクエリを処理した後に残っている壁は (2, 1), (2, 4) の 2 個です。
入力例 2
5 5 5 3 3 3 3 3 2 2 2 1 2
出力例 2
10
入力例 3
4 3 10 2 2 4 1 1 1 4 2 2 1 3 1 1 3 1 2 4 3 4 2
出力例 3
2
Score : 400 points
Problem Statement
There is a grid with H rows and W columns. Let (i, j) denote the cell at the i-th row from the top and j-th column from the left.
Initially, there is one wall in each cell.
After processing Q queries explained below in the order they are given, find the number of remaining walls.
In the q-th query, you are given two integers R_q and C_q.
You place a bomb at (R_q, C_q) to destroy walls. As a result, the following process occurs.
- If there is a wall at (R_q, C_q), destroy that wall and end the process.
- If there is no wall at (R_q, C_q), destroy the first walls that appear when looking up, down, left, and right from (R_q, C_q). More precisely, the following four processes occur simultaneously:
- If there exists an i \lt R_q such that a wall exists at (i, C_q) and no wall exists at (k, C_q) for all i \lt k \lt R_q, destroy the wall at (i, C_q).
- If there exists an i \gt R_q such that a wall exists at (i, C_q) and no wall exists at (k, C_q) for all R_q \lt k \lt i, destroy the wall at (i, C_q).
- If there exists a j \lt C_q such that a wall exists at (R_q, j) and no wall exists at (R_q, k) for all j \lt k \lt C_q, destroy the wall at (R_q, j).
- If there exists a j \gt C_q such that a wall exists at (R_q, j) and no wall exists at (R_q, k) for all C_q \lt k \lt j, destroy the wall at (R_q, j).
Constraints
- 1 \leq H, W
- H \times W \leq 4 \times 10^5
- 1 \leq Q \leq 2 \times 10^5
- 1 \leq R_q \leq H
- 1 \leq C_q \leq W
- All input values are integers.
Input
The input is given from Standard Input in the following format:
H W Q R_1 C_1 R_2 C_2 \vdots R_Q C_Q
Output
Print the number of remaining walls after processing all queries.
Sample Input 1
2 4 3 1 2 1 2 1 3
Sample Output 1
2
The process of handling the queries can be explained as follows:
- In the 1st query, (R_1, C_1) = (1, 2). There is a wall at (1, 2), so the wall at (1, 2) is destroyed.
- In the 2nd query, (R_2, C_2) = (1, 2). There is no wall at (1, 2), so the walls at (2,2),(1,1),(1,3), which are the first walls that appear when looking up, down, left, and right from (1, 2), are destroyed.
- In the 3rd query, (R_3, C_3) = (1, 3). There is no wall at (1, 3), so the walls at (2,3),(1,4), which are the first walls that appear when looking up, down, left, and right from (1, 3), are destroyed.
After processing all queries, there are two remaining walls, at (2, 1) and (2, 4).
Sample Input 2
5 5 5 3 3 3 3 3 2 2 2 1 2
Sample Output 2
10
Sample Input 3
4 3 10 2 2 4 1 1 1 4 2 2 1 3 1 1 3 1 2 4 3 4 2
Sample Output 3
2
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 475 点
問題文
長さ N の数列 A = (A_1, A_2, \dots, A_N) および整数 K があります。
A をいくつかの連続部分列に分割する方法は 2^{N-1} 通りありますが、そのうち分割後に要素の和が K である列が存在しない分割の方法は何通りありますか。答えを 998244353 で割った余りを求めてください。
ここで、「A をいくつかの連続部分列に分割する」とは次の手順のことを言います。
- 分割後の数列の個数 k (1 \leq k \leq N) および 1 = i_1 \lt i_2 \lt \dots \lt i_k \lt i_{k+1} = N+1 を満たす整数列 (i_1, i_2, \dots, i_k, i_{k+1}) を自由に選ぶ。
- 1 \leq n \leq k について、n 番目の数列を、A の i_n 番目から i_{n+1} - 1 番目までの要素を順番を保ったまま取り出して出来る数列とする。
A = (1, 2, 3, 4, 5) のときの分割の例を以下に挙げます。
- (1, 2, 3), (4), (5)
- (1, 2), (3, 4, 5)
- (1, 2, 3, 4, 5)
制約
- 1 \leq N \leq 2 \times 10^5
- -10^{15} \leq K \leq 10^{15}
- -10^9 \leq A_i \leq 10^9
- 入力される値は全て整数
入力
入力は以下の形式で標準入力から与えられる。
N K A_1 A_2 \dots A_N
出力
答えを 998244353 で割った余りを出力せよ。
入力例 1
3 3 1 2 3
出力例 1
2
問題文の条件を満たす分割は次の 2 通りです。
- (1), (2, 3)
- (1, 2, 3)
入力例 2
5 0 0 0 0 0 0
出力例 2
0
入力例 3
10 5 -5 -1 -7 6 -6 -2 -5 10 2 -10
出力例 3
428
Score : 475 points
Problem Statement
You are given a sequence A = (A_1, A_2, \dots, A_N) of length N and an integer K.
There are 2^{N-1} ways to divide A into several contiguous subsequences. How many of these divisions have no subsequence whose elements sum to K? Find the count modulo 998244353.
Here, "to divide A into several contiguous subsequences" means the following procedure.
- Freely choose the number k (1 \leq k \leq N) of subsequences and an integer sequence (i_1, i_2, \dots, i_k, i_{k+1}) satisfying 1 = i_1 \lt i_2 \lt \dots \lt i_k \lt i_{k+1} = N+1.
- For each 1 \leq n \leq k, the n-th subsequence is formed by taking the i_n-th through (i_{n+1} - 1)-th elements of A, maintaining their order.
Here are some examples of divisions for A = (1, 2, 3, 4, 5):
- (1, 2, 3), (4), (5)
- (1, 2), (3, 4, 5)
- (1, 2, 3, 4, 5)
Constraints
- 1 \leq N \leq 2 \times 10^5
- -10^{15} \leq K \leq 10^{15}
- -10^9 \leq A_i \leq 10^9
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N K A_1 A_2 \dots A_N
Output
Print the count modulo 998244353.
Sample Input 1
3 3 1 2 3
Sample Output 1
2
There are two divisions that satisfy the condition in the problem statement:
- (1), (2, 3)
- (1, 2, 3)
Sample Input 2
5 0 0 0 0 0 0
Sample Output 2
0
Sample Input 3
10 5 -5 -1 -7 6 -6 -2 -5 10 2 -10
Sample Output 3
428
Time Limit: 5 sec / Memory Limit: 1024 MiB
配点 : 575 点
問題文
円形のケーキがあり、ケーキは切り目によって N 個のピースに分けられています。各切り目は円の中心と円弧上の点を結ぶ線分です。
ピースおよび切り目には時計回りに 1, 2, \ldots, N の番号が付けられており、ピース i の質量は A_i です。ピース 1 をピース N + 1 とも呼ぶこととします。
切り目 i は ピース i とピース i + 1 の間にあり、ピース 1, 切り目 1, ピース 2, 切り目 2, \ldots, ピース N, 切り目 N の順に時計回りに並んでいます。
このケーキを以下の条件を満たすように K 人に分けようとしています。ただし、i 番目の人が受け取るピースの質量の合計を w_i とします。
- すべての人が 1 つ以上の連続するピースを受け取る
- 誰も受け取らないピースは存在しない
- 上の 2 つの条件を満たすという条件下で \min(w_1, w_2, \ldots, w_K) が最大になるようにする
条件を満たす分け方における \min(w_1, w_2, \ldots, w_K) の値および条件を満たすすべての分け方で切られることのない切り目の個数を求めてください。ただし、切り目 i が切られるとは、ピース i とピース i + 1 が異なる人に分けられることを指します。
制約
- 2 \leq K \leq N \leq 2 \times 10^5
- 1 \leq A_i \leq 10^4
- 入力される値はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N K A_1 A_2 \ldots A_N
出力
条件を満たす分け方における \min(w_1, w_2, \ldots, w_K) の値を x、 切られることのない切り目の個数を y として、x と y をこの順に空白区切りで出力せよ。
入力例 1
5 2 3 6 8 6 4
出力例 1
13 1
以下の分け方が条件を満たします。
- 一方の人にピース 2, 3 を渡し、もう一方の人にピース 4, 5, 1 を渡す。ピース 2, 3 の質量の合計は 14、ピース 4, 5, 1 の質量の合計は 13 である。
- 一方の人にピース 3, 4 を渡し、もう一方の人にピース 5, 1, 2 を渡す。ピース 3, 4 の質量の合計は 14、ピース 5, 1, 2 の質量の合計は 13 である。
条件を満たす分け方における \min(w_1, w_2) の値は 13 であり、どちらの分け方でも切られない切り目は切り目 5 の 1 つです。
入力例 2
6 3 4 7 11 3 9 2
出力例 2
11 1
入力例 3
10 3 2 9 8 1 7 9 1 3 5 8
出力例 3
17 4
Score : 575 points
Problem Statement
There is a circular cake divided into N pieces by cut lines. Each cut line is a line segment connecting the center of the circle to a point on the arc.
The pieces and cut lines are numbered 1, 2, \ldots, N in clockwise order, and piece i has a mass of A_i. Piece 1 is also called piece N + 1.
Cut line i is between pieces i and i + 1, and they are arranged clockwise in this order: piece 1, cut line 1, piece 2, cut line 2, \ldots, piece N, cut line N.
We want to divide this cake among K people under the following conditions. Let w_i be the sum of the masses of the pieces received by the i-th person.
- Each person receives one or more consecutive pieces.
- There are no pieces that no one receives.
- Under the above two conditions, \min(w_1, w_2, \ldots, w_K) is maximized.
Find the value of \min(w_1, w_2, \ldots, w_K) in a division that satisfies the conditions, and the number of cut lines that are never cut in the divisions that satisfy the conditions. Here, cut line i is considered cut if pieces i and i + 1 are given to different people.
Constraints
- 2 \leq K \leq N \leq 2 \times 10^5
- 1 \leq A_i \leq 10^4
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N K A_1 A_2 \ldots A_N
Output
Let x be the value of \min(w_1, w_2, \ldots, w_K) in a division that satisfies the conditions, and y be the number of cut lines that are never cut. Print x and y in this order, separated by a space.
Sample Input 1
5 2 3 6 8 6 4
Sample Output 1
13 1
The following divisions satisfy the conditions:
- Give pieces 2, 3 to one person and pieces 4, 5, 1 to the other. Pieces 2, 3 have a total mass of 14, and pieces 4, 5, 1 have a total mass of 13.
- Give pieces 3, 4 to one person and pieces 5, 1, 2 to the other. Pieces 3, 4 have a total mass of 14, and pieces 5, 1, 2 have a total mass of 13.
The value of \min(w_1, w_2) in divisions satisfying the conditions is 13, and there is one cut line that is not cut in either division: cut line 5.
Sample Input 2
6 3 4 7 11 3 9 2
Sample Output 2
11 1
Sample Input 3
10 3 2 9 8 1 7 9 1 3 5 8
Sample Output 3
17 4
Time Limit: 4 sec / Memory Limit: 1024 MiB
配点 : 650 点
問題文
正整数 n の正の約数の総和が 3 で割り切れる時、n を良い整数と呼びます。
正整数 N, M が与えられます。長さ M の正整数列 A のうち、 A の要素の総積が N 以下の良い整数になるものの個数を 998244353 で割った余りを求めてください。
制約
- 1 \leq N \leq 10^{10}
- 1 \leq M \leq 10^5
- N, M は整数
入力
入力は以下の形式で標準入力から与えられる。
N M
出力
答えを出力せよ。
入力例 1
10 1
出力例 1
5
条件を満たす数列は次の 5 個です。
- (2)
- (5)
- (6)
- (8)
- (10)
入力例 2
4 2
出力例 2
2
条件を満たす数列は次の 2 個です。
- (1, 2)
- (2, 1)
入力例 3
370 907
出力例 3
221764640
入力例 4
10000000000 100000
出力例 4
447456146
Score : 650 points
Problem Statement
We call a positive integer n a good integer if and only if the sum of its positive divisors is divisible by 3.
You are given two positive integers N and M. Find the number, modulo 998244353, of length-M sequences A of positive integers such that the product of the elements in A is a good integer not exceeding N.
Constraints
- 1 \leq N \leq 10^{10}
- 1 \leq M \leq 10^5
- N and M are integers.
Input
The input is given from Standard Input in the following format:
N M
Output
Print the answer.
Sample Input 1
10 1
Sample Output 1
5
There are five sequences that satisfy the conditions:
- (2)
- (5)
- (6)
- (8)
- (10)
Sample Input 2
4 2
Sample Output 2
2
There are two sequences that satisfy the conditions:
- (1, 2)
- (2, 1)
Sample Input 3
370 907
Sample Output 3
221764640
Sample Input 4
10000000000 100000
Sample Output 4
447456146