SHARE
TWEET

Untitled

vafin20 Jun 30th, 2020 955 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.     int n;
  6.     cin >> n; // кол-во
  7.     int x,y;
  8.     int min_r = 10001;
  9.     int sum = 0;
  10.  
  11.     for(int i = 0; i < n; ++i) {
  12.         cin >> x >> y;
  13.         if (x*x > y*y) {
  14.             sum += x*x;
  15.             if (x*x - y*y < min_r && (x*x - y*y) % 3 != 0) {
  16.                 min_r = x*x - y*y;
  17.             }
  18.         }
  19.         else {
  20.             sum += y*y;
  21.             if (y*y - x*x < min_r && (y*y - x*x) % 3 != 0)
  22.                 min_r = y*y - x*x;
  23.         }
  24.     }
  25.  
  26.     if(sum % 3 == 0) {
  27.         if(min_r != 10001) {
  28.             sum -= min_r;
  29.             cout << sum << endl;
  30.         }
  31.         else {
  32.             cout << "0" << endl;
  33.         }
  34.     }
  35.     else {
  36.         cout << sum << endl;
  37.     }
  38.     return 0;
  39. }
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