/
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
高橋君は、お菓子パーティーの幹事を任されました。
高橋君は N 種類のお菓子を用意しており、i 番目の種類のお菓子は A_i 個あります。これらのお菓子を、パーティーに参加する M 人の友人に配りたいと考えています。
それぞれの種類のお菓子について、M 人全員に同じ個数ずつ配ることにします。このとき、各種類ごとに、1 人あたりに配れる個数と、配りきれずに余る個数を求めてください。
すなわち、各 i = 1, 2, \ldots, N について、A_i = M \times Q_i + R_i かつ 0 \le R_i < M を満たす非負整数の組 (Q_i, R_i) を求めてください。
制約
- 1 \leq N \leq 2 \times 10^5
- 1 \leq M \leq 10^9
- 0 \leq A_i \leq 10^9 (1 \leq i \leq N)
- 入力はすべて整数である。
入力
N M A_1 A_2 \ldots A_N
- 1 行目には、お菓子の種類数を表す整数 N と、友人の人数を表す整数 M が、スペース区切りで与えられる。
- 2 行目には、各種類のお菓子の個数を表す整数 A_1, A_2, \ldots, A_N が、スペース区切りで与えられる。
出力
N 行出力してください。
i 行目には、A_i を M で割った商 Q_i と余り R_i を、スペース区切りで出力してください。
入力例 1
3 4 10 7 3
出力例 1
2 2 1 3 0 3
入力例 2
5 3 0 1 2 3 6
出力例 2
0 0 0 1 0 2 1 0 2 0
入力例 3
8 7 100 49 50 0 35 1 999 123
出力例 3
14 2 7 0 7 1 0 0 5 0 0 1 142 5 17 4
入力例 4
10 1000000000 999999999 1000000000 500000000 0 1 999999998 123456789 987654321 2000000 750000000
出力例 4
0 999999999 1 0 0 500000000 0 0 0 1 0 999999998 0 123456789 0 987654321 0 2000000 0 750000000
入力例 5
1 1 0
出力例 5
0 0
Score : 200 pts
Problem Statement
Takahashi has been appointed as the organizer of a snack party.
Takahashi has prepared N types of snacks, and there are A_i pieces of the i-th type of snack. He wants to distribute these snacks among the M friends attending the party.
For each type of snack, he will distribute the same number of pieces to all M people. For each type, find the number of pieces each person receives and the number of pieces that remain undistributed.
In other words, for each i = 1, 2, \ldots, N, find the pair of non-negative integers (Q_i, R_i) satisfying A_i = M \times Q_i + R_i and 0 \le R_i < M.
Constraints
- 1 \leq N \leq 2 \times 10^5
- 1 \leq M \leq 10^9
- 0 \leq A_i \leq 10^9 (1 \leq i \leq N)
- All input values are integers.
Input
N M A_1 A_2 \ldots A_N
- The first line contains an integer N representing the number of types of snacks and an integer M representing the number of friends, separated by a space.
- The second line contains integers A_1, A_2, \ldots, A_N representing the number of pieces of each type of snack, separated by spaces.
Output
Print N lines.
On the i-th line, print the quotient Q_i and the remainder R_i when A_i is divided by M, separated by a space.
Sample Input 1
3 4 10 7 3
Sample Output 1
2 2 1 3 0 3
Sample Input 2
5 3 0 1 2 3 6
Sample Output 2
0 0 0 1 0 2 1 0 2 0
Sample Input 3
8 7 100 49 50 0 35 1 999 123
Sample Output 3
14 2 7 0 7 1 0 0 5 0 0 1 142 5 17 4
Sample Input 4
10 1000000000 999999999 1000000000 500000000 0 1 999999998 123456789 987654321 2000000 750000000
Sample Output 4
0 999999999 1 0 0 500000000 0 0 0 1 0 999999998 0 123456789 0 987654321 0 2000000 0 750000000
Sample Input 5
1 1 0
Sample Output 5
0 0