Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.InputStreamReader;
- import java.util.Comparator;
- import java.util.StringTokenizer;
- public class B {
- public static void main(String[] args)throws Exception {
- STDIN scan = new STDIN();
- int n = scan.nextInt();
- int[] arr = new int[n];
- for(int i = 0 ; i < n ;++i) {
- arr[i] = scan.nextInt();
- }
- if(valid(arr,0,0)) {
- System.out.println("YES");
- }
- else {
- System.out.println("NO");
- }
- }
- private static boolean valid(int[] arr, int i, int sum) {
- if(i == arr.length && sum % 360 == 0)
- return true;
- if(i >= arr.length)
- return false;
- return valid(arr,i+1,sum + arr[i]) || valid(arr,i+1,sum - arr[i]);
- }
- public static class STDIN{
- BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
- StringTokenizer st;
- String next()throws Exception{
- while(st == null || !st.hasMoreTokens())
- st = new StringTokenizer(br.readLine());
- return st.nextToken();
- }
- int nextInt()throws Exception{
- return Integer.parseInt(next());
- }
- String nextLine()throws Exception{
- return br.readLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement