#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
using namespace std;
typedef long long ll;
const int maxn=
300+
10;
ll dp[maxn][maxn];
ll sum[maxn][maxn];
int m,n;
int gcd(
int a,
int b)
{
return b==
0?a:gcd(b,a%
b);
}
void init()
{
memset(dp,0,
sizeof(dp));
memset(sum,0,
sizeof(sum));
for(
int i=
1;i<=
300;i++
)
for(
int j=
1;j<=
300;j++
)
{
dp[i][j]=dp[i-
1][j]+dp[i][j-
1]-dp[i-
1][j-
1]+(ll)(gcd(i,j)==
1);
//存的是可以到这个点的点的数量
}
for(
int i=
1;i<=
300;i++
)
for(
int j=
1;j<=
300;j++
)
{
sum[i][j]+=sum[i-
1][j]+sum[i][j-
1]-sum[i-
1][j-
1]+dp[i][j]-dp[i/
2][j/
2];
//由点存边
}
}
int main()
{
init();
while(~scanf(
"%d%d",&n,&m)&&(m+
n))
{
printf("%lld\n",sum[n-
1][m-
1]*
2LL);
}
return 0;
}
转载于:https://www.cnblogs.com/Wangwanxiang/p/8433165.html
相关资源:数据结构—成绩单生成器
转载请注明原文地址: https://win8.8miu.com/read-1495438.html