XDU 1031
#include<stdio.h> #define maxn 1005 int c[maxn][maxn]; int gcd(int a,int b){ return b==0?a:gcd(b,a%b); } int main() { int n,m,ans,tmp; while(scanf("%d%d",&n,&m)!=EOF){ ans=0; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ tmp=gcd(i,j); ans+=(i+j)/tmp; } } printf("%d\n",ans); } }