fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4.  
  5. void solve()
  6. {
  7. int n; cin >> n;
  8. vector<int> v(n);
  9. ll sum = 0, product = 1;
  10. for (auto&i:v)
  11. {
  12. cin >> i;
  13. sum += i;
  14. product *= i;
  15. }
  16. // 4 + x = 3x => 4 = 3x-x ==> 4 = 2x == > x = 4/2
  17. for (auto&i:v)
  18. {
  19. ll s = sum - i;
  20. ll p = product / i;
  21. double sd = s, pd = p;
  22. double xd = sd/(pd-1);
  23. ll x = s/(p-1);
  24. if (x == xd)
  25. {
  26. if (s+x == p*x && x != i)
  27. {
  28. cout << "Yes";
  29. return;
  30. }
  31. }
  32. }
  33. cout << "No";
  34. }
  35.  
  36. int main()
  37. {
  38. #ifndef ONLINE_JUDGE
  39. freopen("input.txt", "r", stdin);
  40. freopen("output.txt", "w", stdout);
  41. freopen("Errors.txt", "w", stderr);
  42. #endif
  43. ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  44. int t = 1;
  45. // cin >> t;
  46. while (t--)
  47. {
  48. solve();
  49. if (t) cout << '\n';
  50. }
  51. cout << '\n';
  52. return 0;
  53. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
No