selfcompiler's blog

By selfcompiler, 10 years ago, In English

I tried this Problem but getting WA ,I don't know why i am keep getting WA .If some one find out the fault in my code that would be great help!!

Your code here...
#include<iostream>
#include<cstdio>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<vector>
using namespace std;

#define si(x) scanf("%d",&x);
#define s2i(a,b) si(a)si(b)
#define sl(x) scanf("%I64",&x);
#define s2l(a,b) sl(a)sl(b)
#define ss(x) scanf("%s",x);

#define pi(x) printf("%d",x);
#define pl(x) printf("%I64",x);
#define ps(x) printf("%s",x);
#define line printf("\n");
#define space printf(" ");
#define p2i(a,b) pi(a) space pi(b)
#define p2l(a,b) pl(a) space pl(b)

#define vinit(_size_,_value_) resize(_size_,_value_)
#define _mem(value,_array_) memset(_array_,0,sizeof(_array_))
#define ULL long long int
//#define ULL unsigned long long int
#define _pi pair<int,int> 
#define _pl pair<LL,LL>
#define _vi vector<int> 
#define _vl vector<LL>
#define _vpi vector< _pi >
#define _vpl vector< _pl >

#define _f first
#define _s second
#define _pb push_back
#define _mp make_pair
ULL mygcd(ULL a,ULL b)
{
        ULL c;
        while(a!=0)
        {
           c=a;a=b%a;b=c;
        }
        return b;
}
ULL mylcm(ULL a,ULL b)
{
    ULL ans=a;
    ans=ans/mygcd(a,b);
    ans=ans*b;
    return ans;
}
ULL N,M,g,x,y,gx,gy,go,k;
int main()
{
    int tc;
    cin>>tc;
    while(tc--)
    {
       scanf("%lld%lld",&M,&N);
       g=mygcd(M,N);
       if(g==1)
       {
               cout<<M*N<<endl;
               continue;  
       }
       x=M/g;
       y=N/g;
       k=x*y;
       gx=mygcd(g,x);
       gy=mygcd(g,y);
       k=k*gx*gy;
      printf("%lld\n",k);
   
    }
    return 0;
}

`

  • Vote: I like it
  • 0
  • Vote: I do not like it