1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
| #include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i,a,n) for (int i=a;i<n;i++)
int yzcnt[100010];
void init(){ rep(i,1,100001) yzcnt[i]++; rep(i,2,100001){ rep(j,1,100000/i+1){ if(i*j<100001){ yzcnt[i*j]++; } } } }
int gcd(int a,int b){ return b==0?a:gcd(b,a%b); }
ll calc(ll *v1,ll *v2,ll *v3){ if(v1 == v2 && v2 == v3){ return (*v1)*(*v1+1)*(*v1+2)/6; } if(v1 == v2){ return (*v3)*((*v1+1)*(*v1)/2); } if(v2 == v3){ return (*v1)*((*v2+1)*(*v2)/2); } if(v3 == v1){ return (*v2)*((*v3+1)*(*v3)/2); } return (*v1)*(*v2)*(*v3); }
int ec(int a,int b,int c){ return c+7*(b+7*a); }
int main(){ init(); int t; cin>>t; while(t-->0){ int v[3]; scanf("%d %d %d",v,v+1,v+2); int gab= gcd(v[0],v[1]); int gbc= gcd(v[1],v[2]); int gca= gcd(v[2],v[0]); int gabc= gcd(gab,v[2]);
ll a = yzcnt[v[0]] - yzcnt[gab] - yzcnt[gca] + yzcnt[gabc]; ll b = yzcnt[v[1]] - yzcnt[gbc] - yzcnt[gab] + yzcnt[gabc]; ll c = yzcnt[v[2]] - yzcnt[gca] - yzcnt[gbc] + yzcnt[gabc]; ll ab = yzcnt[gab] - yzcnt[gabc]; ll bc = yzcnt[gbc] - yzcnt[gabc]; ll ca = yzcnt[gca] - yzcnt[gabc]; ll abc = yzcnt[gabc];
ll *slotA[] = {&a,&ab,&ca,&abc}; ll *slotB[] = {&b,&bc,&ab,&abc}; ll *slotC[] = {&c,&ca,&bc,&abc};
int slotMaskA[] = {0,3,5,6}; int slotMaskB[] = {1,4,3,6}; int slotMaskC[] = {2,5,4,6}; bool masks[7*7*7]; rep(i,0,7*7*7){ masks[i] = false; }
ll ans = 0; rep(i,0,4){ rep(j,0,4){ rep(k,0,4){ int maskarr[] = {slotMaskA[i],slotMaskB[j],slotMaskC[k]}; sort(maskarr,maskarr+3); int code = ec(maskarr[0],maskarr[1],maskarr[2]); if(!masks[code]){ masks[code] = true; ans +=calc(slotA[i],slotB[j],slotC[k]); } } } } printf("%lld\n",ans); }
return 0; }
|