#F. C - Triangular Relationship

    传统题 1000ms 256MiB

C - Triangular Relationship

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

C - Triangular Relationship

Score : $300$ points

Problem Statement

You are given integers $N$ and $K$. Find the number of triples $(a,b,c)$ of positive integers not greater than $N$ such that $a+b,b+c$ and $c+a$ are all multiples of $K$. The order of $a,b,c$ does matter, and some of them can be the same.

Constraints

  • $1 \leq N,K \leq 2\times 10^5$
  • $N$ and $K$ are integers.

Input

Input is given from Standard Input in the following format:

NN KK

Output

Print the number of triples $(a,b,c)$ of positive integers not greater than $N$ such that $a+b,b+c$ and $c+a$ are all multiples of $K$.


3 2
9

$(1,1,1),(1,1,3),(1,3,1),(1,3,3),(2,2,2),(3,1,1),(3,1,3),(3,3,1)$ and $(3,3,3)$ satisfy the condition.


5 3
1

31415 9265
27

35897 932
114191

2024寒假入门组刷题营(二)

未参加
状态
已结束
规则
ACM/ICPC
题目
8
开始于
2024-1-30 13:30
结束于
2024-1-30 15:30
持续时间
2 小时
主持人
参赛人数
9