Advertisement
a53

PerecheCMMDC

a53
Dec 12th, 2019
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int n , a , b , amax = 0 , bmax = 0, dmax = -1;
  8. cin >> n;
  9. for( ; n ; --n)
  10. {
  11. cin >> a >> b;
  12. int x = a , y = b;
  13. while(y)
  14. {
  15. int r = x % y;
  16. x= y;
  17. y = r;
  18. }
  19.  
  20. if(x > dmax)
  21. dmax = x, amax = a , bmax = b;
  22. else
  23. if(x == dmax)
  24. if(a + b > amax + bmax)
  25. amax= a , bmax = b;
  26.  
  27. }
  28. cout << amax << " " << bmax;
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement