Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Softuniada_2017
- {
- class Program
- {
- static string output = "No";
- static void Main(string[] args)
- {
- int[] numbers = Console.ReadLine()
- .Split()
- .Select(int.Parse)
- .ToArray();
- IsSumAchievable(numbers , 0);
- Console.WriteLine(output);
- }
- static void IsSumAchievable(int[] numbers,int index)
- {
- if (index == 3)
- {
- return;
- }
- for (int i = 0; i < 2 && output == "No"; i++)
- {
- numbers[index] = i == 0 ? Math.Abs(numbers[index]) : 0 - Math.Abs(numbers[index]);
- int sum = numbers.Sum();
- if (sum == 13)
- {
- output = "Yes";
- return;
- }
- else
- {
- IsSumAchievable(numbers, index + 1);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement