Chia hết

View as PDF

Submit solution

Points: 0.40
Time limit: 1.0s
Memory limit: 128M
Input: stdin
Output: stdout

Author:
Problem type

Cho một mảng gồm ~n~ số từ 1 đến ~n~, hỏi có bao nhiêu cặp cộng lại chia hết cho ~k~?

Input

Dòng đầu tiên gồm 2 số ~n~ và ~k~ ~(2 \leq n \leq 10^9, 2 \leq k \leq 10^6)~

Output

Một số duy nhất là số cặp thỏa mãn yêu cầu đề bài.

Cách tính điểm

  • 30% số điểm ~(2 \leq n \leq 10^3, 2 \leq k \leq 10^3)~
  • 40% số điểm ~(2 \leq n \leq 10^6, 2 \leq k \leq 10^6)~
  • 30% số điểm ~(2 \leq n \leq 10^9, 2 \leq k \leq 10^6)~

Sample input 1

5 2

Sample output2

4

Giải thích

từ các số: ~1, 2, 3, 4, 5~ có thể tạo ra các cặp tổng của chúng chia hết cho 2 là: {1, 3}, {1, 5}, {3, 5}, {2, 4}.


Comments

Please read the guidelines before commenting.


There are no comments at the moment.