QM13A - editorial

PROBLEM LINK:

Practice

Contest

Author: Chandan Boruah

Tester: Chandan Boruah

Editorialist: Chandan Boruah

DIFFICULTY:

SIMPLE

PREREQUISITES:

SORTING

PROBLEM:

Given four numbers find if three of them add up to the fourth.

QUICK EXPLANATION:

Add the smallest three numbers and find if they add up to the largest one.

EXPLANATION:

Sort the four numbers, add up the first three and find if they add up to the fourth. Since, we are summing so the last number will be the number that we add up to.
approaches.

AUTHOR’S C# SOLUTIONS:

using System;
using System.Collections.Generic;
class some
{
	public static void Main()
	{
		string[]s=Console.ReadLine().Split();
		int[]arr=new int[s.Length];
		for(int i=0;i<s.Length;i++)arr[i]=int.Parse(s[i]);
		Array.Sort(arr);
		if(arr[0]+arr[1]+arr[2]==arr[3])Console.WriteLine(1);
		else Console.WriteLine(0);
	}
}
//