1 #include<iostream>
2 #include<stdio.h>
3 #include<cstring>
4 #include<cstdlib>
5 using namespace std;
6
7 typedef long long LL;
8 const int maxn = 1e5+7;
9 bool s[maxn];
10 int prime[maxn],len = 0;
11 int mu[maxn];
12 int sum1[maxn];
13 void init()
14 {
15 memset(s,true,sizeof(s));
16 mu[1] = 1;
17 for(int i=2;i<maxn;i++)
18 {
19 if(s[i] == true)
20 {
21 prime[++len] = i;
22 mu[i] = -1;
23 }
24 for(int j=1;j<=len && (long long)prime[j]*i<maxn;j++)
25 {
26 s[i*prime[j]] = false;
27 if(i%prime[j]!=0)
28 mu[i*prime[j]] = -mu[i];
29 else
30 {
31 mu[i*prime[j]] = 0;
32 break;
33 }
34 }
35 }
36 for(int i=1;i<maxn;i++)
37 sum1[i] = sum1[i-1]+mu[i];
38 }
39
40 int main()
41 {
42 int a,b,n,m;
43 init();
44 while(scanf("%d%d",&a,&b)>0)
45 {
46 if(a>b) swap(a,b);
47 LL sum = 0;
48 LL ans ;
49 for(int i=1;i<=a;i++)
50 {
51 n = a/i;
52 m = b/i;
53 ans = 0;
54 if(n>m) swap(n,m);
55 for(int j=1,la = 0; j<=n;j=la+1)
56 {
57 la = min(n/(n/j),m/(m/j));
58 ans = ans + (long long)(sum1[la] - sum1[j-1])*(n/j)*(m/j);
59 }
60 sum = sum + (long long)ans*(2*i-1);
61 }
62 printf("%lld\n",sum);
63 }
64 return 0;
65 }
1 //package ttMain;
2
3 import java.math.BigDecimal;
4 import java.math.BigInteger;
5 import java.util.Scanner;
6
7 public class Main{
8
9 static long f[] = new long[100003];
10 public static void main(String[] args) {
11 Scanner cin = new Scanner(System.in);
12 int a = cin.nextInt();
13 int b = cin.nextInt();
14 fun(a,b);
15 int tmp = min(a,b);
16 BigInteger sum = BigInteger.ZERO;
17 for(int i=1;i<=tmp;i++)
18 sum = sum.add(BigInteger.valueOf(f[i]).multiply(BigInteger.valueOf(i)));
19 sum = sum.multiply(BigInteger.valueOf(2));
20 BigInteger fone = BigInteger.valueOf(-1);
21 fone = fone.multiply(BigInteger.valueOf(a).multiply(BigInteger.valueOf(b)));
22 sum = sum.add(fone);
23 System.out.println(sum);
24 }
25 private static int min(int a, int b) {
26 return a>b? b:a;
27 }
28 private static void fun(int n,int m) {
29 if(n>m) {
30 int tmp = n;
31 n =m;
32 m = tmp;
33 }
34 for(int i=1;i<=n;i++) f[i] = 0;
35 for(int i=n;i>=1;i--)
36 {
37 f[i] = (long)(n/i)*(long)(m/i);
38 for(int j=i+i;j<=n;j=j+i)
39 f[i] = f[i] - f[j];
40 }
41 }
42 }