数学题
容斥一下,个数=总个数-三点共线的个数(垂直x,y轴共线,倾斜共线)
/**************************************************************
Problem: 3505
User: syh0313
Language: C++
Result: Accepted
Time:344 ms
Memory:1288 kb
****************************************************************/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using
namespace
std;
long
long
ans,n,m;
long
long
C(
long
long
x){
return
x*(x-1)/2*(x-2)/3;}
int
main()
{
scanf
(
"%lld%lld"
,&n,&m);
ans=C((n+1)*(m+1)); ans-=(n+1)*C(m+1); ans-=(m+1)*C(n+1);
for
(
int
i=1;i<=n+1;i++)
for
(
int
j=1;j<=m+1;j++) ans-=2ll*(__gcd(i,j)-1)*(n+1-i)*(m+1-j);
printf
(
"%lld\n"
,ans);
return
0;
}