0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-27 18:36:26 +00:00
OI-codes/S2OJ/1732/1732.cpp

29 lines
519 B
C++

#include <iostream>
using std::cin;
using std::cout;
const char endl = '\n';
int n, k;
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> k;
int a = n / k,
b = (n - 1) / k + 1;
int cb = n % k,
ca = k - n % k;
long long res = 0;
res += static_cast<long long>(ca) * (ca - 1) / 2 * a * a;
res += static_cast<long long>(cb) * (cb - 1) / 2 * b * b;
res += static_cast<long long>(a) * b * ca * cb;
cout << res << endl;
return 0;
}