http://blog.csdn.net/zhb1997/article/details/38474795

#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;
int n,m;
ll ans;
int main()
{
//  freopen("bzoj3505.in","r",stdin);
    scanf("%d%d",&n,&m); ++n; ++m;
    ans=(ll)(n*m-2)*(ll)(n*m-1)*(ll)(n*m)/6ll;
    ans-=(ll)n*(ll)(m-2)*(ll)(m-1)*(ll)m/6ll;
    ans-=(ll)m*(ll)(n-2)*(ll)(n-1)*(ll)n/6ll;
    for(int i=1;i<n;++i)
      for(int j=1;j<m;++j)
        if(__gcd(i,j)>1)
          ans-=(ll)(__gcd(i,j)-1)*(ll)(n-i)*(ll)(m-j)*2ll;
    cout<<ans<<endl;
    return 0;
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-20
  • 2021-09-18
  • 2021-12-15
  • 2021-07-26
  • 2022-12-23
  • 2022-01-23
猜你喜欢
  • 2022-02-07
  • 2022-03-04
  • 2022-01-17
  • 2021-11-16
  • 2022-01-27
  • 2022-12-23
相关资源
相似解决方案