fork download
  1. #include <bits/stdc++.h>
  2. #include <string>
  3. using namespace std;
  4. #define ll long long
  5. #define all(a) a.begin(), a.end()
  6. int n; vector<int>a;
  7. bool solve(int i, int sum){
  8. if(i == n){
  9. while(sum < 0) sum += 360;
  10. if(sum % 360 == 0) return true;
  11. return false;
  12. }
  13. solve(i + 1, sum + a[i]);
  14. solve(i + 1, sum - a[i]);
  15. }
  16. int main(){
  17.  
  18. ios::sync_with_stdio(false);
  19. cin.tie(nullptr);
  20. cin >> n;
  21. a.resize(n);
  22. for(int i = 0; i < n; i++) cin >> a[i];
  23. if(solve(0, 0)) cout << "YES\n";
  24. else cout << "NO\n";
  25. return 0;
  26. }
  27.  
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
YES