#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

  • 1N,K2×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

周六中心团队 KMP & Mathematics

未参加
状态
已结束
规则
IOI
题目
6
开始于
2023-10-28 14:45
结束于
2023-10-30 14:45
持续时间
48 小时
主持人
参赛人数
23