Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <stack>
- #include <queue>
- #include <iomanip>
- #include <fstream>
- #include <set>
- #include <sstream>
- #include <map>
- #include <limits>
- #include <bitset>
- #include <memory.h>
- #include <string>
- using namespace std;
- typedef long long ll;
- typedef long double ld;
- typedef pair<ll,ll> pii;
- #define REP(i, n) for (ll i = 0; i < n; i++)
- #define MN(a, b) a = min(a, b)
- #define MX(a, b) a = max(a, b)
- using namespace std;
- bool check(ll x1, ll x2, ll x3, ll x4)
- {
- bool ok = true;
- ok &= (x1 >= 1 && x1 <= 1000000);
- ok &= (x2 >= 1 && x2 <= 1000000);
- ok &= (x3 >= 1 && x3 <= 1000000);
- ok &= (x4 >= 1 && x4 <= 1000000);
- ok &= (x1 + x2 + x3 + x4) == 2*(x2+x3);
- ok &= 2*(x2+x3) == 4*(x4-x1);
- return ok;
- }
- bool check2(ll x1, ll x2, ll x3, ll x4)
- {
- bool ok = true;
- ok &= (4*x1 - x2) == x3;
- ok &= (3*x1) == x4;
- ok &= check(x1,x2,x3,x4);
- ok &= (x1 <= x2);
- ok &= (x2 <= x3);
- ok &= (x3 <= x4);
- return ok;
- }
- int main()
- {
- ios_base::sync_with_stdio(false);
- bool ok = true;
- ll n;
- cin >> n;
- if (n == 4)
- {
- ll x1,x2,x3,x4;
- cin >> x1 >> x2 >> x3 >> x4;
- ok &= check2(x1,x2,x3,x4);
- if (ok) cout << "YES" << endl;
- else cout << "NO" << endl;
- }
- else if (n == 3)
- {
- ll x1,x2,x3,x4;
- cin >> x1 >> x2 >> x3;
- x4 = (x2+x3)/2 + x1;
- ok &= (x2+x3)%2 == 0;
- ok &= check2(x1,x2,x3,x4);
- if (ok) cout << "YES" << endl << x4 << endl;
- else cout << "NO" << endl;
- }
- else if (n == 2)
- {
- ll x1,x2,x3,x4;
- cin >> x1 >> x2;
- x3 = 4*x1 - x2;
- x4 = 3*x1;
- if (x3 > x4) swap(x3,x4);
- ok &= check2(x1,x2,x3,x4);
- if (ok) cout << "YES" << endl << x3 << endl << x4 << endl;
- else cout << "NO" << endl;
- }
- else if (n == 1)
- {
- ll x1,x2,x3,x4;
- cin >> x1;
- x2 = x1;
- x3 = 4*x1 - x2;
- x4 = 3*x1;
- if (x2 > x3) swap(x2, x3);
- if (x2 > x4) swap(x2, x4);
- if (x3 > x4) swap(x3, x4);
- ok &= check2(x1,x2,x3,x4);
- if (ok) cout << "YES" << endl << x2 << endl << x3 << endl << x4 << endl;
- else cout << "NO" << endl;
- }
- else if (n == 0)
- {
- ll x1, x2, x3, x4;
- x1 = 1;
- x2 = 1;
- x3 = 4*x1 - x2;
- x4 = 3*x1;
- ok &= check2(x1,x2,x3,x4);
- if (ok) cout << "YES" << endl << x1 << endl << x2 << endl << x3 << endl << x4 << endl;
- else cout << "NO" << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement