0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 03:31:59 +00:00

P3166 [CQOI2014]数三角形

R52807909
This commit is contained in:
Baoshuo Ren 2021-07-10 22:05:19 +08:00 committed by Baoshuo Ren
parent 08a11da9c6
commit 79558550a7
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

View File

@ -0,0 +1,17 @@
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, m, ans;
cin >> n >> m;
n++, m++;
ans = n * m * (n * m - 1) * (n * m - 2) / 6 - n * m * (m - 1) * (m - 2) / 6 - m * n * (n - 1) * (n - 2) / 6;
for (long long i = 1; i <= n; i++) {
for (long long j = 1; j <= m; j++) {
ans -= 2ll * (__gcd(i, j) - 1) * (n - i) * (m - j);
}
}
cout << ans << endl;
return 0;
}