2807: OH哥的倍数问题(Easy Version)
#include<stdio.h>
typedef long long LL;
LL n;
LL get(int x){
return (1+n/x)*(n/x)*x/2;}
LL gcd(int a,int b){
return b?gcd(b,a%b):a;}
LL lcm(int a,int b){
return a/gcd(a,b)*b;}
int main()
{
int T;scanf("%d",&T);while(T--){
int a,b;scanf("%lld%d%d",&n,&a,&b);printf("%lld\n",get(a)+get(b)-get(lcm(a,b)));}return 0;
}