SHARE
TWEET

Untitled

GerONSo Jan 24th, 2020 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int n;
  2.     cin >> n;
  3.     vector<int> a(n), b(n);
  4.     for(int i = 0; i < n; i++) {
  5.         cin >> a[i];
  6.     }
  7.     for(int i = 0; i < n; i++) {
  8.         cin >> b[i];
  9.     }
  10.     int cur = 0;
  11.    
  12.     for(int i = 0; i < n; i++) {
  13.         for(int j = 0; j < n; j++) {
  14.             if(__gcd(a[i], b[j]) + __gcd(a[j], b[i]) > __gcd(a[i], b[i]) + __gcd(a[j], b[j])) {
  15.                 swap(a[i], a[j]);
  16.             }
  17.         }
  18.     }
  19.     for(int i = 0; i < n; i++) {
  20.         cur += __gcd(a[i], b[i]);
  21.     }
  22.     cout << cur;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top