git reimport
This commit is contained in:
41
archive/2019.02/2019.02.27 - Hello 2019/TaskB.java
Normal file
41
archive/2019.02/2019.02.27 - Hello 2019/TaskB.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package chelper;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import solutions.ChelperSolution;
|
||||
|
||||
|
||||
public class TaskB extends ChelperSolution {
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
super.solve(testNumber, in, out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
int n = in.nextInt();
|
||||
|
||||
int[] a = in.nextIntArray(n);
|
||||
|
||||
boolean ok = false;
|
||||
|
||||
for (int mask = 0; mask < 1 << n; mask++) {
|
||||
int res = 0;
|
||||
int t = mask;
|
||||
for (int i = 0; i < n; i++) {
|
||||
if ((t & 1) == 0) {
|
||||
res += a[i];
|
||||
} else {
|
||||
res -= a[i];
|
||||
}
|
||||
t /= 2;
|
||||
}
|
||||
|
||||
res = (res % 360 + 360) % 360;
|
||||
ok |= res == 0;
|
||||
}
|
||||
|
||||
out.println(ok ? "YES" : "NO");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user