Advertisement
a53

CMMDC_CMMMC

a53
Dec 12th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. unsigned long long a,b,r,p;
  7. cin>>a>>b;
  8. p=a*b;
  9. if (a==0&&b==0)
  10. cout<<-1;
  11. else
  12. {
  13. if (a<b) swap(a,b);
  14. if (b==0)
  15. cout<<a;
  16. else
  17. {
  18. r=a%b;
  19. while (r)
  20. a=b,b=r,r=a%b;
  21. cout<<b<<' '<<p/b;
  22. }
  23. }
  24. return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement