Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
33
Task/McNuggets-problem/C-sharp/mcnuggets-problem.cs
Normal file
33
Task/McNuggets-problem/C-sharp/mcnuggets-problem.cs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
using System;
|
||||
|
||||
public class McNuggets
|
||||
{
|
||||
public static void Main()
|
||||
{
|
||||
bool[] isMcNuggetNumber = new bool[101];
|
||||
|
||||
for (int x = 0; x <= 100/6; x++)
|
||||
{
|
||||
for (int y = 0; y <= 100/9; y++)
|
||||
{
|
||||
for (int z = 0; z <= 100/20; z++)
|
||||
{
|
||||
int mcNuggetNumber = x*6 + y*9 + z*20;
|
||||
if (mcNuggetNumber <= 100)
|
||||
{
|
||||
isMcNuggetNumber[mcNuggetNumber] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int mnnCheck = isMcNuggetNumber.Length-1; mnnCheck >= 0; mnnCheck--)
|
||||
{
|
||||
if (!isMcNuggetNumber[mnnCheck])
|
||||
{
|
||||
Console.WriteLine("Largest non-McNuggett Number less than 100: " + mnnCheck.ToString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue