AtCoder Beginner Contest 108
翻译中…
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:
翻译中…
N K
翻译中…
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$.
翻译中…
样例
Input #1
3 2
Output #1
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.
Input #2
5 3
Output #2
1
Input #3
31415 9265
Output #3
27
Input #4
35897 932
Output #4
114191
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。