Advertisement
a53

TortO

a53
Dec 26th, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #include <fstream>
  2. using namespace std;
  3.  
  4. int cmmdc(int a,int b)
  5. {
  6. if(a==0&&b==0)
  7. return -1;
  8. else
  9. {
  10. if(a<b)
  11. swap(a,b);
  12. if(b==0)
  13. return a;
  14. else
  15. {
  16. int r=a%b;
  17. while (r)
  18. a=b,b=r,r=a%b;
  19. return b;
  20. }
  21. }
  22. }
  23.  
  24. int main ()
  25. {
  26. int n,m;
  27. ifstream f("tort.in");
  28. f>>n>>m;
  29. f.close();
  30. ofstream g("tort.out");
  31. int d=cmmdc(n,m);
  32. g<<(n/d)*(m/d)<<' '<<d;
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement