daily pastebin goal
11%
SHARE
TWEET

Untitled

a guest Dec 16th, 2018 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma GCC optimize("Ofast")
  2.  
  3. #define _CRT_SECURE_NO_WARNINGS
  4. #define _USE_MATH_DEFINES
  5.  
  6. #include <iostream>
  7. #include <fstream>
  8. #include <stdio.h>
  9. #include <string>
  10. #include <vector>
  11. #include <cmath>
  12. #include <algorithm>
  13. #include <set>
  14. #include <map>
  15. #include <ctime>
  16. #include <cstring>
  17. #include <iomanip>
  18. #include <random>
  19. #include <unordered_set>
  20. #include <unordered_map>
  21. #include <deque>
  22. #include <queue>
  23. #include <bitset>
  24. #include <sstream>
  25.  
  26. using namespace std;
  27.  
  28. #define mp make_pair
  29. #define X first
  30. #define Y second
  31. #define all(x) x.begin(), x.end()
  32. #define all_(x) x.rbegin(), x.rend()
  33. #define multi_test 0
  34.  
  35. typedef unsigned int ui;
  36. typedef long long ll;
  37. typedef unsigned long long ull;
  38. typedef long double ld;
  39. typedef pair<ll, ll> pll;
  40. typedef pair<int, int> pii;
  41.  
  42. const int INF = 1e9 + 9;
  43. const ll INF1 = 1e18 + 9;
  44. const ll MAXN = 4e5 + 7;
  45. const ll MAXN1 = 1 << 11;
  46. const ll MAXN2 = 2e7 + 9;
  47. const ll MOD = 998244353;
  48. const ll MOD1 = 1e9 + 9;
  49. const ll ALPH = 50;
  50. const ll PW1 = 239;
  51. const ll PW2 = 199;
  52. const ll PW3 = 193;
  53. const ll PW4 = 117;
  54. const ld EPS = 1e-9;
  55. const ll BLOCK = 3684;
  56. const ll BLOCK1 = 1 << 9;
  57.  
  58. void solve();
  59.  
  60. signed main(){
  61.     srand('a' + 'l' + 'e' + 'x' + 'X' + '5' + '1' + '2');
  62.     ios_base::sync_with_stdio(0);
  63.     cin.tie(0);
  64.     cout.tie(0);
  65. #ifdef _DEBUG
  66. #define MAXN 2007
  67.     freopen("input.txt", "r", stdin);
  68.     freopen("output.txt", "w", stdout);
  69. #endif // _DEBUG
  70.     int q = 1;
  71.     if (multi_test) cin >> q;
  72.     while (q--) solve();
  73. }
  74.  
  75. /*-------------------------------------------------------------------------------------------------------------*/
  76.  
  77. ll ans[MAXN], ans1[MAXN];
  78.  
  79. void solve() {
  80.     int n;
  81.     cin >> n;
  82.     vector<ll> v(n / 2);
  83.     for (int i = 0; i < v.size(); ++i) {
  84.         cin >> v[i];
  85.         ll a = 0, b = INF;
  86.         for (int j = 1; j * j <= v[i]; ++j) {
  87.             if (v[i] % j == 0) {
  88.                 int k = v[i] / j;
  89.                 if ((k + j) % 2 != 0) continue;
  90.                 int nb = (k + j) / 2;
  91.                 int na = (k - j) / 2;
  92.                 if (i == 0) {
  93.                     if (nb < b) {
  94.                         a = na, b = nb;
  95.                     }
  96.                 }
  97.                 else if (na > ans[2 * i - 1] && nb < b) {
  98.                     a = na, b = nb;
  99.                 }
  100.             }
  101.         }
  102.         if (b == INF) {
  103.             cout << "No";
  104.             return;
  105.         }
  106.         ans[i * 2] = a;
  107.         ans[i * 2 + 1] = b;
  108.     }
  109.     ans1[0] = ans[0] * ans[0];
  110.     ans1[1] = v[0];
  111.     for (int i = 1; i < v.size(); ++i) {
  112.         ans1[2 * i] = ans[i * 2] * ans[i * 2] - ans[i * 2 - 1] * ans[i * 2 - 1];
  113.         ans1[2 * i + 1] = v[i];
  114.     }
  115.     ll p = 0;
  116.     for (int i = 0; i < n; ++i) {
  117.         p += ans1[i];
  118.         if (p != ll(sqrtl(p)) * ll(sqrtl(p))) {
  119.             cout << "No";
  120.             return;
  121.         }
  122.     }
  123.     cout << "Yes\n";
  124.     for (int i = 0; i < n; ++i) {
  125.         cout << ans1[i] << " ";
  126.     }
  127. }
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