Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection.Metadata;
- using System.Text;
- using System.Threading.Tasks;
- class EqualSums
- {
- static int[] getInts()
- {
- string line = Console.ReadLine();
- string [] strings = line.Split(' ');
- int [] result = new int[strings.Length];
- for(int i = 0; i < result.Length; ++i)
- result[i] = int.Parse(strings[i]);
- return result;
- }
- static void Main()
- {
- int [] ints = getInts();
- if(ints.Length == 1)
- {
- System.Console.WriteLine(0);
- return;
- }
- if(ints.Length == 2)
- {
- if(ints[0] == 0 && ints[0] == ints[1])
- {
- System.Console.WriteLine(0);
- return;
- }
- if(ints[1] == 0 && ints[0] == ints[1])
- {
- System.Console.WriteLine(1);
- return;
- }
- System.Console.WriteLine("no");
- return;
- }
- bool isHave = false;
- int leftSum, rightSum;
- for(int i = 0; i < ints.Length; ++i)
- {
- leftSum = 0; rightSum = 0;
- for(int j = 0; j < i; j++)
- leftSum += ints[j];
- for(int j = i + 1; j < ints.Length; ++j)
- rightSum += ints[j];
- if(leftSum == rightSum)
- {
- System.Console.WriteLine(i);
- isHave = true;
- }
- }
- if(!isHave)
- System.Console.WriteLine("no");
- }
- }
- /*
- 1 2 3 3
- 1 2
- 1
- 1 2 3
- 10 5 5 99 3 4 2 5 1 1 4
- */
Advertisement
Add Comment
Please, Sign In to add comment