Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MainC {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int n = scan.nextInt();
- String s = scan.next();
- int[] arr = new int[n];
- int topSum = 0;
- for (int i = 0; i < n; i++) {
- arr[i] = s.charAt(i) - '0';
- topSum += arr[i];
- }
- if (topSum == 0) {
- System.out.println("YES");
- System.exit(0);
- }
- for (int tSum = 1; tSum < topSum; tSum++) {
- int cSum = 0;
- for (int i = 0; i < n; i++) {
- cSum += arr[i];
- if (cSum == tSum) {
- cSum = 0;
- } else if (cSum > tSum) {
- break;
- }
- }
- if (cSum == 0) {
- System.out.println("YES");
- System.exit(0);
- }
- }
- System.out.println("NO");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement