Skip to content

Instantly share code, notes, and snippets.

Created March 3, 2015 18:45
Show Gist options
  • Save anonymous/9b83afbbfb77b824b268 to your computer and use it in GitHub Desktop.
Save anonymous/9b83afbbfb77b824b268 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
long budle1 = long.Parse(Console.ReadLine());
long budle2 = long.Parse(Console.ReadLine());
long budle3 = long.Parse(Console.ReadLine());
long budle4 = long.Parse(Console.ReadLine());
long T = long.Parse(Console.ReadLine());
long N = long.Parse(Console.ReadLine());
long legs = (budle1*1)+(budle2*2)+(budle3*3)+(budle4*4);
long legsLeft = legs - (T * 4);
long legsPosaibleTables = legs / 4;
long posibleTables = Math.Abs(legsPosaibleTables - T);
if (legsPosaibleTables > T)
{
posibleTables = legsPosaibleTables - posibleTables;
}
else if (T > legsPosaibleTables)
{
posibleTables = T - posibleTables;
}
else
{
posibleTables = T;
}
long tablesNeed = posibleTables - N;
long legsneed = legsPosaibleTables - N;
long topsneed = T - N;
if (tablesNeed == 0)
{
Console.WriteLine("Just enough tables made: {0}",N);
}
else if (posibleTables > N)
{
Console.WriteLine("more: {0} ", Math.Abs(tablesNeed));
Console.WriteLine("tops left: {0}, legs left: {1}", Math.Abs(topsneed),Math.Abs(legsneed*4) );
}
else // if (need > posibleTables)
{
Console.WriteLine("less: {0} ", tablesNeed);
Console.WriteLine("tops needed: {0}, legs needed: {1}", Math.Abs(topsneed), Math.Abs(legsneed*4));
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment