#3045. Triangular Relationship
Triangular Relationship
Background
AtCoder Regular Contest 102-C 你要尽量多看英语
Description
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.
你得到了整数N和K。求不大于N的正整数的三元组(a,b,c)的个数,使得a+b,b+c和c+a都是K的倍数。a,b、c的顺序很重要,其中一些可以是相同的。
Constraints
- 1≤N,K≤2×10^5
- N and Kare integers.
Format
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+aare all multiples of K.
Samples
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
31415 9265
114191
统计
相关
在下列比赛中: