/
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
高橋君は会社の経理担当として、今月の従業員へのボーナス支給を管理しています。
会社には N 人の従業員がおり、それぞれの従業員には業績に応じた報酬額が決まっています。i 番目の従業員の報酬額は P_i 円です。
社長から次のような指示がありました。「報酬額が K の倍数である従業員には、特別手当を支給したい。まずは該当する従業員の報酬額の合計を教えてほしい。」
高橋君を手伝って、報酬額が K の倍数(すなわち P_i が K で割り切れる)である従業員の報酬額の合計を求めてください。該当する従業員がいない場合、合計は 0 です。
制約
- 1 \leq N \leq 2 \times 10^5
- 1 \leq K \leq 10^9
- 1 \leq P_i \leq 10^9
- 入力はすべて整数
入力
N K P_1 P_2 \ldots P_N
- 1 行目には、従業員の人数を表す整数 N と、倍数判定に用いる整数 K が、スペース区切りで与えられる。
- 2 行目には、各従業員の報酬額を表す N 個の整数 P_1, P_2, \ldots, P_N が、スペース区切りで与えられる。
出力
報酬額が K の倍数である従業員の報酬額の合計を 1 行で出力してください。
入力例 1
5 3 6 7 9 12 5
出力例 1
27
入力例 2
8 5 10 25 7 15 30 8 100 3
出力例 2
180
入力例 3
10 1000000 500000 1000000 2000000 3000000 750000 4000000 1234567 5000000 999999 6000000
出力例 3
21000000
Score : 200 pts
Problem Statement
Takahashi is in charge of accounting at his company and is managing this month's bonus payments to employees.
The company has N employees, and each employee has a compensation amount determined by their performance. The compensation amount for the i-th employee is P_i yen.
The company president gave the following instruction: "I would like to give a special allowance to employees whose compensation amount is a multiple of K. First, please tell me the total of the compensation amounts for the applicable employees."
Help Takahashi find the total of the compensation amounts for employees whose compensation amount is a multiple of K (that is, P_i is divisible by K). If there are no such employees, the total is 0.
Constraints
- 1 \leq N \leq 2 \times 10^5
- 1 \leq K \leq 10^9
- 1 \leq P_i \leq 10^9
- All inputs are integers
Input
N K P_1 P_2 \ldots P_N
- The first line contains an integer N representing the number of employees and an integer K used for the divisibility check, separated by a space.
- The second line contains N integers P_1, P_2, \ldots, P_N representing the compensation amounts of each employee, separated by spaces.
Output
Print the total of the compensation amounts for employees whose compensation amount is a multiple of K, on a single line.
Sample Input 1
5 3 6 7 9 12 5
Sample Output 1
27
Sample Input 2
8 5 10 25 7 15 30 8 100 3
Sample Output 2
180
Sample Input 3
10 1000000 500000 1000000 2000000 3000000 750000 4000000 1234567 5000000 999999 6000000
Sample Output 3
21000000