実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 100 点
問題文
英小文字からなる文字列 S が与えられます。
文字列 S の末尾に s を追加した文字列を出力してください。
制約
- S は英小文字からなる長さ 1 以上 10 以下の文字列
入力
入力は以下の形式で標準入力から与えられる。
S
出力
答えを出力せよ。
入力例 1
http
出力例 1
https
http の末尾に s を追加すると https になります。したがって、 https を出力してください。
入力例 2
append
出力例 2
appends
入力例 3
beginner
出力例 3
beginners
Score : 100 points
Problem Statement
You are given a string S consisting of lowercase English letters.
Output the string obtained by appending s to the end of the string S.
Constraints
- S is a string of length between 1 and 10, inclusive, consisting of lowercase English letters.
Input
The input is given from Standard Input in the following format:
S
Output
Output the answer.
Sample Input 1
http
Sample Output 1
https
Appending s to the end of http results in https, so print https.
Sample Input 2
append
Sample Output 2
appends
Sample Input 3
beginner
Sample Output 3
beginners
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 200 点
問題文
年に 1 度の節分には年齢と同じ数の豆を食べます。高橋君はそれ以外に豆を食べることはありません。
高橋君は、今年 ( 0 年後 ) の節分の時点で N 歳です。
高橋君が今年以降 (今年を含む) で累計 K 個以上の豆を食べたことになるのは、最短で何年後の節分ですか?
なお、高橋君は不死身なので、高橋君が今年以降で累計 K 個以上の豆を食べたという状況は必ず訪れます。
制約
- 入力は全て整数
- 1 \le N,K \le 10^8
入力
入力は以下の形式で標準入力から与えられる。
N K
出力
答えを出力せよ。
入力例 1
4 43
出力例 1
6
- 0 年後の節分に高橋君は 4 個の豆を食べ、今年以降で累計で 4 個の豆を食べます。
- 1 年後の節分に高橋君は 5 個の豆を食べ、今年以降で累計で 9 個の豆を食べます。
- 2 年後の節分に高橋君は 6 個の豆を食べ、今年以降で累計で 15 個の豆を食べます。
- 3 年後の節分に高橋君は 7 個の豆を食べ、今年以降で累計で 22 個の豆を食べます。
- 4 年後の節分に高橋君は 8 個の豆を食べ、今年以降で累計で 30 個の豆を食べます。
- 5 年後の節分に高橋君は 9 個の豆を食べ、今年以降で累計で 39 個の豆を食べます。
- 6 年後の節分に高橋君は 10 個の豆を食べ、今年以降で累計で 49 個の豆を食べます。
6 年後の節分の時点で累計 43 個以上の豆を食べたことになるので、 6 と出力してください。
入力例 2
100000000 100000000
出力例 2
0
今年のみで食べた豆の個数が K 個以上に達することもあります。
入力例 3
1234 12345678
出力例 3
3886
Score : 200 points
Problem Statement
At the annual Setsubun festival, one eats the same number of beans as their age. Takahashi-kun does not eat beans at any other time.
He is N years old at this year's Setsubun (0 years later).
At the earliest, how many years later will he have eaten a total of K or more beans from this year onward (including this year)?
He is immortal, so he will eventually have eaten a total of K or more beans from this year onward.
Constraints
- All input values are integers.
- 1 \le N,K \le 10^8
Input
The input is given from Standard Input in the following format:
N K
Output
Print the answer.
Sample Input 1
4 43
Sample Output 1
6
- At Setsubun 0 years later, Takahashi-kun eats 4 beans, totaling 4 beans from this year onward.
- At Setsubun 1 year later, he eats 5 beans, totaling 9 beans from this year onward.
- At Setsubun 2 years later, he eats 6 beans, totaling 15 beans from this year onward.
- At Setsubun 3 years later, he eats 7 beans, totaling 22 beans from this year onward.
- At Setsubun 4 years later, he eats 8 beans, totaling 30 beans from this year onward.
- At Setsubun 5 years later, he eats 9 beans, totaling 39 beans from this year onward.
- At Setsubun 6 years later, he eats 10 beans, totaling 49 beans from this year onward.
At Setsubun 6 years later, he will have eaten a total of 43 or more beans, so output 6.
Sample Input 2
100000000 100000000
Sample Output 2
0
The number of beans eaten this year alone may reach K or more.
Sample Input 3
1234 12345678
Sample Output 3
3886
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 300 点
問題文
AtCoder 社は時刻 0 に始業し時刻 T に終業します。 時刻 t と時刻 t+1 との間隔は 1 秒です。
高橋君は AtCoder 社の業務時間中に SNS の chokutter を以下の規則で見ます。
- 始業と同時に chokutter を開く。
- 青木君が高橋君のデスクの後ろを通りかかった瞬間に chokutter を開いていた場合、直ちに chokutter を閉じる。
- 高橋君は、 chokutter を時刻 t に閉じると、時刻 t+100 に必ず chokutter を開く。
始業から終業までに N 回青木君が高橋君のデスクの後ろを通りかかっており、そのうち i 回目は時刻 A_i でした。
始業から終業までに、高橋君は合計で何秒 chokutter を見ていましたか?
なお、 高橋君が chokutter を開いた瞬間に青木君がデスクの後ろを通りかかることはありませんでした。
制約
- 入力は全て整数
- 0 \le N \le 3 \times 10^5
- 1 \le A_1 < A_2 < \dots < A_N \le T \le 10^9
- 高橋君が chokutter を開いた瞬間に青木君がデスクの後ろを通りかかることはない
入力
入力は以下の形式で標準入力から与えられる。
N T A_1 A_2 \dots A_N
出力
答えを出力せよ。
入力例 1
5 700 100 150 300 350 700
出力例 1
500
- 時刻 0 に高橋君は chokutter を開きます。
- 時刻 100 に青木君が高橋君のデスクの後ろを通りかかり、高橋君は直ちに chokutter を閉じます。
- 時刻 150 に青木君が高橋君のデスクの後ろを通りかかりますが、高橋君はこの時点で chokutter を開いていません。
- 時刻 200 に高橋君は再び chokutter を開きます。
- 時刻 300 に青木君が高橋君のデスクの後ろを通りかかり、高橋君は直ちに chokutter を閉じます。
- 時刻 350 に青木君が高橋君のデスクの後ろを通りかかりますが、高橋君はこの時点で chokutter を開いていません。
- 時刻 400 に高橋君は再び chokutter を開きます。
- 時刻 700 に青木君が高橋君のデスクの後ろを通りかかり、高橋君は直ちに chokutter を閉じます。
高橋君は、合計で 500 秒間 chokutter を見ていました。
入力例 2
0 1000000000
出力例 2
1000000000
青木君が高橋君のデスクの後ろを通りかかることがない場合もあります。
入力例 3
10 1234 395 424 588 745 773 863 910 958 1102 1195
出力例 3
734
Score : 300 points
Problem Statement
AtCoder Inc. starts work at time 0 and ends work at time T. The interval between time t and time t+1 is 1 second.
Takahashi-kun views the SNS chokutter during AtCoder Inc.'s business hours according to the following rules:
- He opens chokutter at the same time as work starts.
- If chokutter is open at the moment Aoki-kun passes behind Takahashi-kun's desk, he immediately closes it.
- If Takahashi-kun closes chokutter at time t, he always opens it at time t+100.
From the start to the end of work, Aoki-kun passed behind Takahashi-kun's desk N times, with the i-th time being at time A_i.
From the start to the end of work, for how many seconds in total was Takahashi-kun viewing chokutter?
Aoki-kun never passed behind the desk at the moment when Takahashi-kun opened chokutter.
Constraints
- All input values are integers.
- 0 \le N \le 3 \times 10^5
- 1 \le A_1 < A_2 < \dots < A_N \le T \le 10^9
- Aoki-kun never passes behind the desk at the moment when Takahashi-kun opens chokutter.
Input
The input is given from Standard Input in the following format:
N T A_1 A_2 \dots A_N
Output
Output the answer.
Sample Input 1
5 700 100 150 300 350 700
Sample Output 1
500
- At time 0, Takahashi-kun opens chokutter.
- At time 100, Aoki-kun passes behind Takahashi-kun's desk, and Takahashi-kun immediately closes chokutter.
- At time 150, Aoki-kun passes behind Takahashi-kun's desk, but Takahashi-kun does not have chokutter open at this time.
- At time 200, Takahashi-kun opens chokutter again.
- At time 300, Aoki-kun passes behind Takahashi-kun's desk, and Takahashi-kun immediately closes chokutter.
- At time 350, Aoki-kun passes behind Takahashi-kun's desk, but Takahashi-kun does not have chokutter open at this time.
- At time 400, Takahashi-kun opens chokutter again.
- At time 700, Aoki-kun passes behind Takahashi-kun's desk, and Takahashi-kun immediately closes chokutter.
Takahashi-kun was viewing chokutter for a total of 500 seconds.
Sample Input 2
0 1000000000
Sample Output 2
1000000000
There may be cases where Aoki-kun never passes behind Takahashi-kun's desk.
Sample Input 3
10 1234 395 424 588 745 773 863 910 958 1102 1195
Sample Output 3
734
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 400 点
問題文
N \times N のマス目があり、各列に 1 つずつ駒が置かれています。
i 列目の駒は上から R_i 行目に置かれています。
あなたは以下の操作を 0 回以上何度でも行うことができます。
- 一番上の行以外に存在する駒をひとつ選び、その駒を 上に隣接するマス に移動させる。
以下の条件を 1 \le i \le N-1 を満たす全ての整数 i について満たすようにするために必要な操作回数の最小値を求めて下さい。
- i 列目の駒が上から x 行目、 i+1 列目の駒が上から y 行目に存在するとする。このとき、 |x-y| \le 1 を満たす。
T 個のテストケースが与えられるので、それぞれについて答えを求めてください。
制約
- 入力は全て整数
- 1 \le T \le 50000
- 2 \le N \le 3 \times 10^5
- 1 \le R_i \le N
- ひとつの入力について、 N の総和は 3 \times 10^5 を超えない
入力
入力は以下の形式で標準入力から与えられる。
T
\text{case}_1
\text{case}_2
\vdots
\text{case}_T
各テストケースは以下の形式で与えられる。
N R_1 R_2 \dots R_N
出力
T 行出力せよ。
i 行目には i 番目のテストケースに対する答えを出力せよ。
入力例 1
5 5 5 2 1 3 4 2 1 1 3 1 3 1 9 9 9 8 2 4 4 3 5 3 20 7 4 6 2 15 5 17 15 1 8 18 1 5 1 12 11 2 7 8 14
出力例 1
4 0 1 16 105
この入力には 5 個のテストケースが含まれます。
1 番目のテストケースについて、以下の通り操作を行うことで 4 回の操作で問題文中の条件を満たすことができ、これが最小です。
- 左から 5 列目の駒を上に隣接するマスに移動させる。 駒は左の列から順に 5,2,1,3,3 行目に存在する。
- 左から 1 列目の駒を上に隣接するマスに移動させる。 駒は左の列から順に 4,2,1,3,3 行目に存在する。
- 左から 1 列目の駒を上に隣接するマスに移動させる。 駒は左の列から順に 3,2,1,3,3 行目に存在する。
- 左から 4 列目の駒を上に隣接するマスに移動させる。 駒は左の列から順に 3,2,1,2,3 行目に存在する。
2 番目のテストケースについて、操作を行わなくても問題文中の条件を満たしています。
Score : 400 points
Problem Statement
There is an N \times N grid, and there is one piece placed in each column.
The piece in column i is placed in row R_i from the top.
You can perform the following operation zero or more times:
- Choose a piece that is not in the topmost row and move that piece to the cell directly above it.
Find the minimum number of operations needed to satisfy the following condition for all integers i satisfying 1 \le i \le N-1:
- Let the piece in column i be in row x from the top and the piece in column i+1 be in row y from the top. Then, |x-y| \le 1.
You are given T test cases; solve each of them.
Constraints
- All input values are integers.
- 1 \le T \le 50000
- 2 \le N \le 3 \times 10^5
- 1 \le R_i \le N
- For a single input, the sum of N does not exceed 3 \times 10^5.
Input
The input is given from Standard Input in the following format:
T
\text{case}_1
\text{case}_2
\vdots
\text{case}_T
Each test case is given in the following format:
N R_1 R_2 \dots R_N
Output
Output T lines.
The i-th line should contain the answer for the i-th test case.
Sample Input 1
5 5 5 2 1 3 4 2 1 1 3 1 3 1 9 9 9 8 2 4 4 3 5 3 20 7 4 6 2 15 5 17 15 1 8 18 1 5 1 12 11 2 7 8 14
Sample Output 1
4 0 1 16 105
This input contains five test cases.
For the first test case, by performing operations as follows, you can satisfy the condition in the problem statement with four operations, which is the minimum.
- Move the piece in the 5-th column from the left to the cell directly above it. The pieces are in rows 5,2,1,3,3 from left to right.
- Move the piece in the 1-st column from the left to the cell directly above it. The pieces are in rows 4,2,1,3,3 from left to right.
- Move the piece in the 1-st column from the left to the cell directly above it. The pieces are in rows 3,2,1,3,3 from left to right.
- Move the piece in the 4-th column from the left to the cell directly above it. The pieces are in rows 3,2,1,2,3 from left to right.
For the second test case, the condition is satisfied without performing any operations.
実行時間制限: 4 sec / メモリ制限: 1024 MiB
配点 : 450 点
問題文
N \times N のマス目があります。このマス目の上から i 行目、左から j 列目を (i,j) と呼びます。
マス目の情報は N 個の文字列 S_1,S_2,\dots,S_N として与えられ、 S_i の j 文字目が . のとき (i,j) は空きマス、 # のとき (i,j) は壁マスです。
はじめ、高橋君は空きマス (N,C) におり、以下の移動を N-1 回繰り返します。
- 現在高橋君が (r,c) にいるとき、 (r-1,c-1),(r-1,c),(r-1,c+1) のいずれかを移動先として指定する。但し、マス目中に存在しないマスを移動先として指定することはできない。
- もし移動先 (a,b) が壁マスである場合、以下のことが起こる。
- 現時点で a < i \le N を満たす全ての整数について (i,b) が空きマスであった場合、 (a,b) にある壁を破壊し、移動する。すなわち、 (a,b) は空きマスになり、高橋君は (a,b) に移動する。
- そうでない場合、高橋君は移動に失敗する。この場合、移動が N-1 回に満たなくとも直ちに移動の繰り返しを終了する。
- もし移動先 (a,b) が空きマスである場合、高橋君は (a,b) に移動する。
以下の条件を満たす長さ N の文字列 R を出力してください。
- もし移動中に失敗せず (1,i) に辿り着ける場合、 R の i 文字目は
1 - そうでない場合、 R の i 文字目は
0
T 個のテストケースが与えられるので、それぞれについて答えを求めてください。
制約
- T,N,C は整数
- 1 \le T \le 50000
- 2 \le N \le 3000
- 1 \le C \le N
- S_i は
.と#からなる長さ N の文字列 - S_N の C 文字目は
. - ひとつの入力について、 N^2 の総和は 9 \times 10^6 を超えない
入力
入力は以下の形式で標準入力から与えられる。
T
\text{case}_1
\text{case}_2
\vdots
\text{case}_T
各テストケースは以下の形式で与えられる。
N C S_1 S_2 \vdots S_N
出力
T 行出力せよ。
i 行目には i 番目のテストケースに対する答えを出力せよ。
入力例 1
5 5 3 .###. ..#.. #.#.# #...# ##..# 2 2 ## .. 4 1 #### #### #### .### 3 3 ... ... ... 10 3 ##.##.##.# .####..#.. ...#.#..#. .#.#.#.#.. ...####... #.#.##.... .##...#... #.##.....# #....###.# .#..#.#...
出力例 1
10111 11 1000 111 0011010010
この入力には 5 個のテストケースが含まれます。
1 番目のテストケースについて、例えば以下のようにして移動中に失敗せず (1,3) に辿り着くことができます。
- はじめ、高橋君は (5,3) にいる。
- 空きマス (4,2) に移動する。
- (3,3) は壁マスであるが、現時点で (4,3),(5,3) は共に空きマスであるため、高橋君は (3,3) にある壁を破壊して (3,3) に移動する。
- (2,3) は壁マスであるが、現時点で (3,3),(4,3),(5,3) は共に空きマスであるため、高橋君は (2,3) にある壁を破壊して (2,3) に移動する。
- (1,3) は壁マスであるが、現時点で (2,3),(3,3),(4,3),(5,3) は共に空きマスであるため、高橋君は (1,3) にある壁を破壊して (1,3) に移動する。
移動中に失敗せず (1,1),(1,3),(1,4),(1,5) には辿り着くことができるので、 10111 と出力してください。
Score : 450 points
Problem Statement
There is an N \times N grid. The cell at the i-th row from the top and j-th column from the left is called (i,j).
The grid is described by N strings S_1,S_2,\dots,S_N. If the j-th character of S_i is ., (i,j) is an empty cell; if it is #, (i,j) is a wall cell.
Initially, Takahashi-kun is at empty cell (N,C), and repeats the following movement N-1 times:
- If he is currently at (r,c), he specifies one of (r-1,c-1),(r-1,c),(r-1,c+1) as the destination. Here, he cannot specify a cell that does not exist in the grid as the destination.
- If the destination (a,b) is a wall cell, the following occurs:
- If (i,b) is currently an empty cell for all integers satisfying a < i \le N, he destroys the wall at (a,b) and moves there. That is, (a,b) becomes an empty cell and he moves to (a,b).
- Otherwise, he fails to move. In this case, he immediately ends the repetition of movements, even if he has not made N-1 movements.
- If the destination (a,b) is an empty cell, he moves to (a,b).
Output a string R of length N satisfying the following conditions:
- If he can reach (1,i) without failing during the movements, the i-th character of R is
1. - Otherwise, the i-th character of R is
0.
You are given T test cases; solve each of them.
Constraints
- T,N,C are integers.
- 1 \le T \le 50000
- 2 \le N \le 3000
- 1 \le C \le N
- S_i is a string of length N consisting of
.and#. - The C-th character of S_N is
.. - For each input, the sum of N^2 does not exceed 9 \times 10^6.
Input
The input is given from Standard Input in the following format:
T
\text{case}_1
\text{case}_2
\vdots
\text{case}_T
Each test case is given in the following format:
N C S_1 S_2 \vdots S_N
Output
Print T lines.
The i-th line should contain the answer for the i-th test case.
Sample Input 1
5 5 3 .###. ..#.. #.#.# #...# ##..# 2 2 ## .. 4 1 #### #### #### .### 3 3 ... ... ... 10 3 ##.##.##.# .####..#.. ...#.#..#. .#.#.#.#.. ...####... #.#.##.... .##...#... #.##.....# #....###.# .#..#.#...
Sample Output 1
10111 11 1000 111 0011010010
This input contains five test cases.
For the first test case, for example, he can reach (1,3) without failing during the movements as follows:
- Initially, he is at (5,3).
- He moves to empty cell (4,2).
- (3,3) is a wall cell, but since (4,3),(5,3) are currently both empty cells, he destroys the wall at (3,3) and moves to (3,3).
- (2,3) is a wall cell, but since (3,3),(4,3),(5,3) are currently all empty cells, he destroys the wall at (2,3) and moves to (2,3).
- (1,3) is a wall cell, but since (2,3),(3,3),(4,3),(5,3) are currently all empty cells, he destroys the wall at (1,3) and moves to (1,3).
He can reach (1,1),(1,3),(1,4),(1,5) without failing during the movements, so print 10111.
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 525 点
問題文
以下の条件を満たす正整数 X を 良い整数 とします。
- X を十進法で表記したとき一の位、十の位、\ldots が広義単調減少になっている。
- より厳密には、\displaystyle X=\sum_{i=0}^{\infty} d_i10^i (0\le d_i < 10) を満たす唯一の非負整数列 (d_0,d_1,\ldots) が広義単調減少列になっている。
例えば、 112389 や 1 、777 は良い整数ですが、 443 や 404 は良い整数ではありません。
正整数 N が与えられます。
N の倍数であるような良い整数が存在するか判定し、存在する場合はその最小値を求めてください。
制約
- 1\le N\le 3\times 10^6
- 入力される値は整数
入力
入力は以下の形式で標準入力から与えられる。
N
出力
N の倍数であるような良い整数が存在しない場合は -1 を出力せよ。
存在する場合は N の倍数であるような良い整数の最小値を出力せよ。
入力例 1
21
出力例 1
126
126 は 21 の倍数であり、 6 \geq 2 \geq 1 \geq 0 \geq \ldots が成り立つため良い整数です。 126 未満の 21 の倍数であるような良い整数は存在しないため、 126 を出力してください。
入力例 2
10
出力例 2
-1
入力例 3
3
出力例 3
3
入力例 4
1089
出力例 4
9999999999999999999999
答えが 2^{64} 以上になる場合があります。
Score : 525 points
Problem Statement
A positive integer X is called a good integer if and only if it satisfies the following condition:
- When X is written in decimal notation, the ones digit, tens digit, \ldots form a non-increasing sequence.
- More formally, the unique non-negative integer sequence (d_0,d_1,\ldots) satisfying \displaystyle X=\sum_{i=0}^{\infty} d_i10^i (0\le d_i < 10) forms a non-increasing sequence.
For example, 112389, 1, and 777 are good integers, but 443 and 404 are not good integers.
You are given a positive integer N.
Determine whether there exists a good integer that is a multiple of N, and if it exists, find its minimum value.
Constraints
- 1\le N\le 3\times 10^6
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N
Output
If there does not exist a good integer that is a multiple of N, output -1.
If it exists, output the minimum value of a good integer that is a multiple of N.
Sample Input 1
21
Sample Output 1
126
126 is a multiple of 21, and we have 6 \geq 2 \geq 1 \geq 0 \geq \ldots, so it is a good integer. There does not exist a good integer less than 126 that is a multiple of 21, so output 126.
Sample Input 2
10
Sample Output 2
-1
Sample Input 3
3
Sample Output 3
3
Sample Input 4
1089
Sample Output 4
9999999999999999999999
The answer may be 2^{64} or greater.
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 575 点
問題文
整数 N,M,A,B が与えられます。
整数列 X=(X_0,X_1,\ldots,X_{N-1}) を \displaystyle X_k = (Ak+B) \bmod M として定義します。
X_k > k を満たす 0 以上 N 未満の整数 k の個数を求めてください。
T 個のテストケースが与えられるので、それぞれについて答えを求めてください。
制約
- 1\le T\le 3\times 10^5
- 1\le N \le M\le 10^9
- 0\le A,B < M
- 入力される値は全て整数
入力
入力は以下の形式で標準入力から与えられる。
T
\text{case}_1
\text{case}_2
\vdots
\text{case}_T
各テストケースは以下の形式で与えられる。
N M A B
出力
各テストケースに対する答えを順に改行区切りで出力せよ。
入力例 1
4 4 6 4 3 7 7 3 1 10 46 0 12 443 2026 131 210
出力例 1
2 3 10 395
1 つ目のテストケースについて考えます。
- k=0 のとき: X_0=(4\times 0+3)\bmod 6=3 なので、 X_k>k が成立します。
- k=1 のとき: X_1=(4\times 1+3)\bmod 6=1 なので、 X_k>k は成立しません。
- k=2 のとき: X_2=(4\times 2+3)\bmod 6=5 なので、 X_k>k が成立します。
- k=3 のとき: X_3=(4\times 3+3)\bmod 6=3 なので、 X_k>k は成立しません。
以上より、X_k>k が成立する 0 以上 4 未満の整数 k は k=0,2 の 2 個です。したがって、 1 行目には 2 を出力してください。
Score : 575 points
Problem Statement
You are given integers N,M,A,B.
Define an integer sequence X=(X_0,X_1,\ldots,X_{N-1}) as \displaystyle X_k = (Ak+B) \bmod M.
Find the number of integers k satisfying 0 \le k < N and X_k > k.
You are given T test cases; solve each of them.
Constraints
- 1\le T\le 3\times 10^5
- 1\le N \le M\le 10^9
- 0\le A,B < M
- All input values are integers.
Input
The input is given from Standard Input in the following format:
T
\text{case}_1
\text{case}_2
\vdots
\text{case}_T
Each test case is given in the following format:
N M A B
Output
Output the answers for the test cases in order, separated by newlines.
Sample Input 1
4 4 6 4 3 7 7 3 1 10 46 0 12 443 2026 131 210
Sample Output 1
2 3 10 395
Consider the first test case.
- When k=0: X_0=(4\times 0+3)\bmod 6=3, so X_k>k holds.
- When k=1: X_1=(4\times 1+3)\bmod 6=1, so X_k>k does not hold.
- When k=2: X_2=(4\times 2+3)\bmod 6=5, so X_k>k holds.
- When k=3: X_3=(4\times 3+3)\bmod 6=3, so X_k>k does not hold.
From the above, the integers k satisfying 0 \le k < 4 and X_k>k are k=0,2, which is two integers. Thus, output 2 on the first line.