Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- public class Main
- {
- public static Scanner in = new Scanner(System.in);;
- int ar[];
- int n;
- int c;
- int sum(int s, int f)
- {
- int sum = 0;
- for(int i = s; i < f; i++)sum += ar[i];
- return sum;
- }
- void init(int n)
- {
- this.n = n;
- ar = new int[n];
- c = 0;
- }
- void read()
- {
- in.nextLine();
- String s = in.nextLine();
- String sp[] = s.split("[ ]");
- for(int i = 0;i < n; i++)ar[i] = Integer.parseInt(sp[i]);
- }
- void doJob()
- {
- for(int i = 1; i < n-1;i++)
- {
- if(sum(0, i) == sum(i, n)){ c++; }
- }
- }
- public static void main()
- {
- System.out.println("enter input");
- int j = in.nextInt();
- Main ob = new Main();
- ob.init(j);
- ob.read();
- ob.doJob();
- System.out.println(ob.c);
- }
- }
Add Comment
Please, Sign In to add comment