実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 100 点
問題文
0123456789 に加えて 10,11,12,13,14,15 に対応する数字として ABCDEF を使う 16 進表記では、0 以上 255 以下の整数は 1 桁または 2 桁になります。
例えば、0 や 12 は 16 進表記では 0 や C と 1 桁になり、99 や 255 は 16 進表記では 63 や FF と 2 桁になります。
0 以上 255 以下の整数 N を、必要に応じて先頭に 0 を加えることでちょうど 2 桁の 16 進表記に変換してください。
注記
英大文字と英小文字は区別されます。特に、16 進表記の数字として ABCDEF の代わりに abcdef を使うことは出来ません。
制約
- 0 \leq N \leq 255
- N は整数
入力
入力は以下の形式で標準入力から与えられる。
N
出力
答えを出力せよ。
入力例 1
99
出力例 1
63
99 は 16 進表記で 63 です。
入力例 2
12
出力例 2
0C
12 は 16 進表記で C です。
要求されているのはちょうど 2 桁の 16 進表記に変換することなので、C の先頭に 0 を加えた 0C が答えです。
入力例 3
0
出力例 3
00
入力例 4
255
出力例 4
FF
Score : 100 points
Problem Statement
In the hexadecimal system, where the digits ABCDEF corresponding to 10,11,12,13,14, and 15 are used in addition to 0123456789, every integer between 0 and 255 is represented as a 1- or 2-digit numeral.
For example, 0 and 12 are represented as 1-digit hexadecimal numerals 0 and C; 99 and 255 are represented as 2-digit hexadecimals 63 and FF.
Given an integer N between 0 and 255, convert it to an exactly two-digit hexadecimal numeral, prepending leading 0s if necessary.
Notes
The judge is case-sensitive. Specifically, you cannot use abcdef as hexadecimal digits instead of ABCDEF.
Constraints
- 0 \leq N \leq 255
- N is an integer.
Input
The input is given from Standard Input in the following format:
N
Output
Print the answer.
Sample Input 1
99
Sample Output 1
63
99 is represented as 63 in hexadecimal.
Sample Input 2
12
Sample Output 2
0C
12 is represented as C in hexadecimal.
Since we ask you to convert it to a two-digit hexadecimal numeral, the answer is 0C, where 0 is prepended to C.
Sample Input 3
0
Sample Output 3
00
Sample Input 4
255
Sample Output 4
FF
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 100 点
問題文
英小文字のみからなる文字列 S が与えられます。
S の各文字を英大文字に変換して得られる文字列 T を出力してください。
制約
- S は英小文字のみからなる、長さが 1 以上 100 以下の文字列
入力
入力は以下の形式で標準入力から与えられる。
S
出力
T を出力せよ。
入力例 1
abc
出力例 1
ABC
abc の各文字を英大文字に変換すると ABC になります。
入力例 2
a
出力例 2
A
入力例 3
abcdefghjiklnmoqprstvuwxyz
出力例 3
ABCDEFGHJIKLNMOQPRSTVUWXYZ
Score : 100 points
Problem Statement
You are given a string S consisting of lowercase English letters.
Uppercase each character of S and print the resulting string T.
Constraints
- S is a string consisting of lowercase English letters whose length is between 1 and 100, inclusive.
Input
The input is given from Standard Input in the following format:
S
Output
Print T.
Sample Input 1
abc
Sample Output 1
ABC
Uppercase each character of abc, and you have ABC.
Sample Input 2
a
Sample Output 2
A
Sample Input 3
abcdefghjiklnmoqprstvuwxyz
Sample Output 3
ABCDEFGHJIKLNMOQPRSTVUWXYZ
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 200 点
問題文
次の図に示す、各マスが黒または白に塗られた縦 15 行 \times 横 15 列のグリッドにおいて、 上から R 行目、左から C 列目のマスが何色かを出力して下さい。

制約
- 1 \leq R, C \leq 15
- R, C は整数
入力
入力は以下の形式で標準入力から与えられる。
R C
出力
図のグリッドにおいて上から R 行目、左から C 列目のマスが黒色の場合は black と、白色の場合は white と出力せよ。
ジャッジは英小文字と英大文字を厳密に区別することに注意せよ。
入力例 1
3 5
出力例 1
black
図のグリッドにおいて上から 3 行目、左から 5 列目のマスは黒色です。
よって、black と出力します。
入力例 2
4 5
出力例 2
white
図のグリッドにおいて上から 4 行目、左から 5 列目のマスは白色です。
よって、white と出力します。
Score : 200 points
Problem Statement
Print the color of the cell at the R-th row from the top and C-th column from the left in the following grid with 15 vertical rows and 15 horizontal columns.

Constraints
- 1 \leq R, C \leq 15
- R and C are integers.
Input
Input is given from Standard Input in the following format:
R C
Output
In the grid above, if the color of the cell at the R-th row from the top and C-th column from the left is black, then print black; if the cell is white, then print white. Note that the judge is case-sensitive.
Sample Input 1
3 5
Sample Output 1
black
In the grid above, the cell at the 3-rd row from the top and 5-th column from the left is black. Thus, black should be printed.
Sample Input 2
4 5
Sample Output 2
white
In the grid above, the cell at the 4-th row from the top and 5-th column from the left is white. Thus, white should be printed.
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 200 点
問題文
4 桁の暗証番号 X_1X_2X_3X_4 が与えられます。 番号は先頭の桁が 0 であることもあり得ます。 暗証番号は以下のいずれかの条件をみたすとき弱い暗証番号と呼ばれます。
- 4 桁とも同じ数字である。
- 1\leq i\leq 3 をみたす任意の整数 i について、 X_{i+1} が、 X_i の次の数字である。 ただし、 0\leq j\leq 8 について j の次の数字は j+1 であり、 9 の次の数字は 0 である。
与えられた暗証番号が弱い暗証番号ならば Weak を、そうでないならば Strong を出力してください。
制約
- 0 \leq X_1, X_2, X_3, X_4 \leq 9
- X_1, X_2, X_3, X_4 は整数である。
入力
入力は以下の形式で標準入力から与えられる。
X_1X_2X_3X_4
出力
与えられた暗証番号が弱い暗証番号ならば Weak を、そうでないならば Strong を出力せよ。
入力例 1
7777
出力例 1
Weak
4 桁ともすべて 7 であるため、 1 つめの条件をみたしており、弱い暗証番号です。
入力例 2
0112
出力例 2
Strong
1 桁目と 2 桁目が異なっており、 3 桁目は 2 桁目の次の数字ではないため、どちらの条件もみたしていません。
入力例 3
9012
出力例 3
Weak
9 の次の数字が 0 であることに注意してください。
Score : 200 points
Problem Statement
You are given a 4-digit PIN: X_1X_2X_3X_4, which may begin with a 0. The PIN is said to be weak when it satisfies one of the following conditions:
- All of the four digits are the same.
- For each integer i such that 1\leq i\leq 3, X_{i+1} follows X_i. Here, j+1 follows j for each 0\leq j\leq 8, and 0 follows 9.
If the given PIN is weak, print Weak; otherwise, print Strong.
Constraints
- 0 \leq X_1, X_2, X_3, X_4 \leq 9
- X_1, X_2, X_3, and X_4 are integers.
Input
Input is given from Standard Input in the following format:
X_1X_2X_3X_4
Output
If the given PIN is weak, print Weak; otherwise, print Strong.
Sample Input 1
7777
Sample Output 1
Weak
All four digits are 7, satisfying the first condition, so this PIN is weak.
Sample Input 2
0112
Sample Output 2
Strong
The first and second digits differ, and the third digit does not follow the second digit, so neither condition is satisfied.
Sample Input 3
9012
Sample Output 3
Weak
Note that 0 follows 9.
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 250 点
問題文
N 種類のビーンズが 1 粒ずつあります。 i 種類目のビーンズはおいしさが A_i で色が C_i です。ビーンズは混ぜられており、色でしか区別することができません。
あなたはビーンズの色を 1 つ選び、その色のビーンズをどれか 1 粒食べます。ビーンズの色をうまく選ぶことで、食べる可能性のあるビーンズのおいしさの最小値を最大化してください。
制約
- 1 \leq N \leq 2 \times 10^{5}
- 1 \leq A_i \leq 10^{9}
- 1 \leq C_i \leq 10^{9}
- 入力は全て整数である。
入力
入力は以下の形式で標準入力から与えられる。
N A_1 C_1 A_2 C_2 \vdots A_N C_N
出力
食べる可能性のあるビーンズのおいしさの最小値の最大値を整数として出力せよ。
入力例 1
4 100 1 20 5 30 5 40 1
出力例 1
40
同じ色のビーンズは互いに区別がつかないことに注意してください。
選ぶことができる色は 色 1 と 色 5 です。
- 色 1 のビーンズは 2 種類あり、美味しさはそれぞれ 100, 40 です。よって、色 1 を選んだときのおいしさの最小値は 40 です。
- 色 5 のビーンズは 2 種類あり、美味しさはそれぞれ 20, 30 です。よって、色 5 を選んだときのおいしさの最小値は 20 です。
おいしさの最小値を最大化するには 色 1 を選べばよいため、そのときの最小値である 40 を出力します。
入力例 2
10 68 3 17 2 99 2 92 4 82 4 10 3 100 2 78 1 3 1 35 4
出力例 2
35
Score: 250 points
Problem Statement
There are N types of beans, one bean of each type. The i-th type of bean has a deliciousness of A_i and a color of C_i. The beans are mixed and can only be distinguished by color.
You will choose one color of beans and eat one bean of that color. By selecting the optimal color, maximize the minimum possible deliciousness of the bean you eat.
Constraints
- 1 \leq N \leq 2 \times 10^{5}
- 1 \leq A_i \leq 10^{9}
- 1 \leq C_i \leq 10^{9}
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N A_1 C_1 A_2 C_2 \vdots A_N C_N
Output
Print as an integer the maximum value of the minimum possible deliciousness of the bean you eat.
Sample Input 1
4 100 1 20 5 30 5 40 1
Sample Output 1
40
Note that beans of the same color cannot be distinguished from each other.
You can choose color 1 or color 5.
- There are two types of beans of color 1, with deliciousness of 100 and 40. Thus, the minimum deliciousness when choosing color 1 is 40.
- There are two types of beans of color 5, with deliciousness of 20 and 30. Thus, the minimum deliciousness when choosing color 5 is 20.
To maximize the minimum deliciousness, you should choose color 1, so print the minimum deliciousness in that case: 40.
Sample Input 2
10 68 3 17 2 99 2 92 4 82 4 10 3 100 2 78 1 3 1 35 4
Sample Output 2
35
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 300 点
問題文
0, 1 のみからなる長さ N の文字列 S が与えられます。
S の中で先頭から K 番目の 1 の塊を K-1 番目の 1 の塊の直後まで移動した文字列を出力してください。
なお、S には 1 の塊が K 個以上含まれることが保証されます。
より正確な説明は以下の通りです。
- S の l 文字目から r 文字目までからなる部分文字列を S_{l\ldots r} と表す。
- S の部分文字列 S_{l\ldots r} が
1の塊であるとは、以下の条件を全て満たすことと定める。- S_l=S_{l+1}=\cdots=S_r=
1 - l=1 または S_{l-1}=
0 - r=N または S_{r+1}=
0
- S_l=S_{l+1}=\cdots=S_r=
- S に含まれる
1の塊が S_{l_1\ldots r_1},\ldots,S_{l_m\ldots r_m} で全てであり、l_1 < \cdots < l_m を満たしているとする。
このとき、以下で定義される長さ N の文字列 T を、「S の中で先頭から K 番目の1の塊を K-1 番目の1の塊の直後まで移動した文字列」と定める- 1 \leq i \leq r_{K-1} のとき T_i = S_i
- r_{K-1}+1 \leq i \leq r_{K-1}+(r_K-l_K)+1 のとき T_i=
1 - r_{K-1}+(r_K-l_K)+2 \leq i \leq r_K のとき T_i=
0 - r_K+1 \leq i \leq N のとき T_i=S_i
制約
- 1 \leq N \leq 5\times 10^5
- S は
0,1のみからなる長さ N の文字列 - 2 \leq K
- S には
1の塊が K 個以上含まれる
入力
入力は以下の形式で標準入力から与えられる。
N K S
出力
答えを出力せよ。
入力例 1
15 3 010011100011001
出力例 1
010011111000001
S には、2 文字目から 2 文字目、5 文字目から 7 文字目、11 文字目から 12 文字目、15 文字目から 15 文字目の 4 つの 1 の塊があります。
入力例 2
10 2 1011111111
出力例 2
1111111110
Score : 300 points
Problem Statement
You are given a string S of length N consisting of 0 and 1.
Move the K-th 1-block from the beginning in S to immediately after the (K-1)-th 1-block, and print the resulting string.
It is guaranteed that S contains at least K 1-blocks.
Here is a more precise description.
- Let S_{l\ldots r} denote the substring of S from the l-th character through the r-th character.
- We define a substring S_{l\ldots r} of S to be a
1-block if it satisfies all of the following conditions:- S_l = S_{l+1} = \cdots = S_r =
1 - l = 1 or S_{l-1} =
0 - r = N or S_{r+1} =
0
- S_l = S_{l+1} = \cdots = S_r =
-
Suppose that all
1-blocks in S are S_{l_1\ldots r_1}, \ldots, S_{l_m\ldots r_m}, where l_1 < l_2 < \cdots < l_m.Then, we define the length N string T, obtained by moving the K-th
1-block to immediately after the (K-1)-th1-block, as follows:- T_i = S_i for 1 \leq i \leq r_{K-1}
- T_i =
1for r_{K-1} + 1 \leq i \leq r_{K-1} + (r_K - l_K) + 1 - T_i =
0for r_{K-1} + (r_K - l_K) + 2 \leq i \leq r_K - T_i = S_i for r_K + 1 \leq i \leq N
Constraints
- 1 \leq N \leq 5 \times 10^5
- S is a string of length N consisting of
0and1. - 2 \leq K
- S contains at least K
1-blocks.
Input
The input is given from Standard Input in the following format:
N K S
Output
Print the answer.
Sample Input 1
15 3 010011100011001
Sample Output 1
010011111000001
S has four 1-blocks: from the 2nd to the 2nd character, from the 5th to the 7th character, from the 11th to the 12th character, and from the 15th to the 15th character.
Sample Input 2
10 2 1011111111
Sample Output 2
1111111110
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 400 点
問題文
長さ N の数列 A=(A_1,A_2,\dots,A_N) が与えられます。この A に以下を施すことを「操作」と呼びます。
- まず、 1 \le i \le N を満たす整数 i を選択する。
- 次に、以下の 2 つのうちどちらかを選択し、実行する。
- A_i に 1 を加算する。
- A_i から 1 を減算する。
Q 個の質問に答えてください。
i 個目の質問は以下です。
- 「操作」を 0 回以上何度でも使って A の要素を全て X_i にする時、必要な「操作」の最小回数を求めてください。
制約
- 入力は全て整数
- 1 \le N,Q \le 2 \times 10^5
- 0 \le A_i \le 10^9
- 0 \le X_i \le 10^9
入力
入力は以下の形式で標準入力から与えられる。
N Q A_1 A_2 \dots A_N X_1 X_2 \vdots X_Q
出力
Q 行にわたって出力せよ。
出力のうち i 行目には、 i 個目の質問に対する答えを整数として出力せよ。
入力例 1
5 3 6 11 2 5 5 5 20 0
出力例 1
10 71 29
A=(6,11,2,5,5) であり、この入力には 3 つの質問が含まれます。
1 つ目の質問について、 A に以下のように 10 回の「操作」を施すことで、 A の要素を全て 5 にすることができます。
- A_1 から 1 減算する。
- A_2 から 1 減算することを 6 度繰り返す。
- A_3 に 1 加算することを 3 度繰り返す。
9 回以下の「操作」で A の要素を全て 5 にすることはできません。
2 つ目の質問について、 A に 71 回の「操作」を施すことで、 A の要素を全て 20 にすることができます。
3 つ目の質問について、 A に 29 回の「操作」を施すことで、 A の要素を全て 0 にすることができます。
入力例 2
10 5 1000000000 314159265 271828182 141421356 161803398 0 777777777 255255255 536870912 998244353 555555555 321654987 1000000000 789456123 0
出力例 2
3316905982 2811735560 5542639502 4275864946 4457360498
出力が 32bit 整数に収まらない場合もあります。
Score : 400 points
Problem Statement
You are given a sequence of length N: A=(A_1,A_2,\dots,A_N). The following action on this sequence is called an operation.
- First, choose an integer i such that 1 \le i \le N.
- Next, choose and do one of the following.
- Add 1 to A_i.
- Subtract 1 from A_i.
Answer Q questions.
The i-th question is the following.
- Consider performing zero or more operations to change every element of A to X_i. Find the minimum number of operations required to do so.
Constraints
- All values in input are integers.
- 1 \le N,Q \le 2 \times 10^5
- 0 \le A_i \le 10^9
- 0 \le X_i \le 10^9
Input
Input is given from Standard Input in the following format:
N Q A_1 A_2 \dots A_N X_1 X_2 \vdots X_Q
Output
Print Q lines.
The i-th line should contain the answer to the i-th question as an integer.
Sample Input 1
5 3 6 11 2 5 5 5 20 0
Sample Output 1
10 71 29
We have A=(6,11,2,5,5) and three questions in this input.
For the 1-st question, you can change every element of A to 5 in 10 operations as follows.
- Subtract 1 from A_1.
- Subtract 1 from A_2 six times.
- Add 1 to A_3 three times.
It is impossible to change every element of A to 5 in 9 or fewer operations.
For the 2-nd question, you can change every element of A to 20 in 71 operations.
For the 3-rd question, you can change every element of A to 0 in 29 operations.
Sample Input 2
10 5 1000000000 314159265 271828182 141421356 161803398 0 777777777 255255255 536870912 998244353 555555555 321654987 1000000000 789456123 0
Sample Output 2
3316905982 2811735560 5542639502 4275864946 4457360498
The output may not fit into 32-bit integers.
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 450 点
問題文
2 次元平面上に N 個の点があります。N は奇数です。 i 番目の点は (x_i, y_i) にあります。全ての点の座標は相異なります。
N 個の点のうち過半数を通る直線が存在するかを判定して、存在すればそれを出力してください。
なお、制約を満たすどのような入力においても、条件を満たす直線が存在する場合、その直線は -10^{18} 以上 10^{18} 以下の整数 a,b,c を用いて ax+by+c=0 と表すことができます。(ただし (a,b,c) \neq (0,0,0)) この a,b,c を出力してください。
制約
- 3 \leq N \leq 5 \times 10^5
- N は奇数
- -10^8 \leq x_i \leq 10^8
- -10^8 \leq y_i \leq 10^8
- i \neq j ならば (x_i, y_i) \neq (x_j, y_j)
- 入力される値は全て整数
入力
入力は以下の形式で標準入力から与えられる。
N x_1 y_1 x_2 y_2 \vdots x_N y_N
出力
条件を満たす直線が存在しない場合は No を出力せよ。
条件を満たす直線が存在する場合は 2 行出力せよ。1 行目には Yes を出力して、2 行目には a,b,c をこの順に空白区切りで出力せよ。a,b,c は -10^{18} 以上 10^{18} 以下かつ (a,b,c) \neq (0,0,0) である必要がある点に注意せよ。
答えが複数ある場合はどれを出力しても正答とみなされる。
入力例 1
3 1 1 3 2 2 4
出力例 1
Yes 2 1 -8
直線 2x+y-8=0 は 2 番目の点と 3 番目の点を通るので条件を満たします。
入力例 2
5 5 2 1 3 2 6 4 4 5 4
出力例 2
No
条件を満たす直線は存在しません。
入力例 3
11 -9374372 85232388 -60705467 86198234 -7475320 80628487 98066347 -23868213 -12177678 85284287 30535572 -35358356 51324557 22410787 28854279 44658587 -28804873 82911971 65052073 8819187 -67744430 68365758
出力例 3
Yes 4655800 4702358 -344340416016346
Score : 450 points
Problem Statement
There are N points on a two-dimensional plane. N is odd. The i-th point is at (x_i, y_i). All point coordinates are distinct.
Determine whether there exists a line passing through more than half of the N points, and if so, output it.
For any input satisfying the constraints, if a line satisfying the condition exists, it can be expressed as ax+by+c=0 using integers a,b,c with -10^{18} \leq a,b,c \leq 10^{18} (where (a,b,c) \neq (0,0,0)). Output these a,b,c.
Constraints
- 3 \leq N \leq 5 \times 10^5
- N is odd.
- -10^8 \leq x_i \leq 10^8
- -10^8 \leq y_i \leq 10^8
- If i \neq j, then (x_i, y_i) \neq (x_j, y_j).
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N x_1 y_1 x_2 y_2 \vdots x_N y_N
Output
If no line satisfying the condition exists, output No.
If a line satisfying the condition exists, output two lines. On the first line, output Yes, and on the second line, output a,b,c in this order separated by spaces. a,b,c must satisfy -10^{18} \leq a,b,c \leq 10^{18} and (a,b,c) \neq (0,0,0).
If there are multiple solutions, any of them will be considered correct.
Sample Input 1
3 1 1 3 2 2 4
Sample Output 1
Yes 2 1 -8
The line 2x+y-8=0 passes through the 2nd and 3rd points, so it satisfies the condition.
Sample Input 2
5 5 2 1 3 2 6 4 4 5 4
Sample Output 2
No
No line satisfying the condition exists.
Sample Input 3
11 -9374372 85232388 -60705467 86198234 -7475320 80628487 98066347 -23868213 -12177678 85284287 30535572 -35358356 51324557 22410787 28854279 44658587 -28804873 82911971 65052073 8819187 -67744430 68365758
Sample Output 3
Yes 4655800 4702358 -344340416016346
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 500 点
問題文
1 から 9 までの数字のみで構成された文字列 S が与えられます。
この文字列 S から、以下の操作によって式 T を作ります。
- はじめ、 T=S であるとする。
- 各要素が 1 以上 |S|-1 以下の整数である、値に重複のない集合 A を選ぶ。なお、 A が空集合であってもよい。
- A の全ての要素 x について、 x の降順に以下の操作を行う。
- T の x 文字目と x+1 文字目の間に、
+を挿入する。
- T の x 文字目と x+1 文字目の間に、
例えば、 S= 1234、 A= \lbrace 2,3 \rbrace であるとき、 T= 12+3+4 となります。
この操作によって得られる T としてあり得る全ての式に対して、式を計算したときの値の総和を 998244353 で割った余りを求めてください。
制約
- 1 \le |S| \le 2 \times 10^5
- S は
1,2,3,4,5,6,7,8,9のみからなる。
入力
入力は以下の形式で標準入力から与えられる。
S
出力
答えを整数として出力せよ。
入力例 1
1234
出力例 1
1736
式 T としてあり得るものは 1234, 123+4, 12+34, 12+3+4, 1+234, 1+23+4, 1+2+34, 1+2+3+4 の 8 つです。
これらを計算した値の総和は 1736 です。
入力例 2
1
出力例 2
1
S の長さが 1 であることもあります。この場合、 A として指定可能なのは空集合のみです。
入力例 3
31415926535897932384626433832795
出力例 3
85607943
答えを 998244353 で割った余りを求めてください。
Score : 500 points
Problem Statement
Given is a string S consisting of digits from 1 through 9.
From this string S, let us make a formula T by the following operations.
- Initially, let T=S.
- Choose a (possibly empty) set A of different integers where each element is between 1 and |S|-1 (inclusive).
- For each element x in descending order, do the following.
- Insert a
+between the x-th and (x+1)-th characters of T.
- Insert a
For example, when S= 1234 and A= \lbrace 2,3 \rbrace, we will have T= 12+3+4.
Consider evaluating all possible formulae T obtained by these operations. Find the sum, modulo 998244353, of the evaluations.
Constraints
- 1 \le |S| \le 2 \times 10^5
- S consists of
1,2,3,4,5,6,7,8, and9.
Input
Input is given from Standard Input in the following format:
S
Output
Print the answer.
Sample Input 1
1234
Sample Output 1
1736
There are eight formulae that can be obtained as T: 1234, 123+4, 12+34, 12+3+4, 1+234, 1+23+4, 1+2+34, and 1+2+3+4.
The sum of the evaluations of these formulae is 1736.
Sample Input 2
1
Sample Output 2
1
S may have a length of 1, in which case the only possible choice for A is the empty set.
Sample Input 3
31415926535897932384626433832795
Sample Output 3
85607943
Be sure to find the sum modulo 998244353.