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;
- namespace ConsoleApplication29
- {
- class Program
- {
- static void Main(string[] args)
- {
- int foundInARow = 0;
- int maxThatCannotBePurchased = 0;
- for (int i = 0; i < 50; i++)
- {
- bool canPurchaseThisAmount = false;
- for (int a = 0; a < i / 6 + 1; a++)
- {
- for (int b = 0; b < i / 9 + 1; b++)
- {
- for (int c = 0; c < i / 20 + 1; c++)
- {
- int solution = (6*a) + (9*b) + (20*c);
- if (solution == i)
- canPurchaseThisAmount = true;
- }
- }
- }
- if (canPurchaseThisAmount)
- {
- foundInARow += 1;
- if (foundInARow == 6)
- break;
- }
- else
- {
- foundInARow = 0;
- maxThatCannotBePurchased = i;
- }
- }
- Console.WriteLine("Largest number of McNuggets that cannot be bought in exact quantity:"+maxThatCannotBePurchased);
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement