Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _10._Profit
- {
- class Program
- {
- static void Main(string[] args)
- {
- //Solution #1
- int oneLevCoins = int.Parse(Console.ReadLine());
- int twoLevCoins = int.Parse(Console.ReadLine());
- int fiveLevCoins = int.Parse(Console.ReadLine());
- int sum = int.Parse(Console.ReadLine());
- int currentSum = 0;
- for (int one = 0; one <= oneLevCoins * 1; one++)
- {
- for (int two = 0; two <= twoLevCoins * 2; two += 2)
- {
- for (int five = 0; five <= fiveLevCoins * 5; five += 5)
- {
- currentSum = one + two + five;
- if (currentSum == sum)
- {
- int onesCount = one / 1;
- int twosCount = two / 2;
- int fivesCount = five / 5;
- Console.WriteLine($"{onesCount} * 1 lv. + {twosCount} * 2 lv. + {fivesCount} * 5 lv. = {currentSum} lv.");
- }
- }
- }
- }
- //Solution #2
- int oneLevCoins = int.Parse(Console.ReadLine());
- int twoLevCoins = int.Parse(Console.ReadLine());
- int fiveLevCoins = int.Parse(Console.ReadLine());
- int sum = int.Parse(Console.ReadLine());
- for (int one = 0; one <= oneLevCoins; one++)
- {
- for (int two = 0; two <= twoLevCoins; two++)
- {
- for (int five = 0; five <= fiveLevCoins; five++)
- {
- if (one * 1 + two * 2 + five * 5 == sum)
- {
- Console.WriteLine($"{one} * 1 lv. + {two} * 2 lv. + {five} * 5 lv. = {sum} lv.");
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement