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;
- using System.Threading.Tasks;
- namespace ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- int m = int.Parse(Console.ReadLine());
- int maxSum = int.Parse(Console.ReadLine());
- int countCombinations = 0;
- int product = 0;
- int sum = 0;
- int totalSum = 0;
- for( int firstNum = n; firstNum >= 1; firstNum--)
- {
- for(int secondNum = 1; secondNum <= m; secondNum ++)
- {
- product = firstNum * secondNum;
- sum = 3 * product;
- totalSum = totalSum + sum;
- countCombinations++;
- if (totalSum >= maxSum)
- {
- Console.WriteLine("{0} combinations", countCombinations);
- Console.WriteLine("Sum: {0} >= {1}", totalSum, maxSum);
- return;
- }
- }
- }
- Console.WriteLine("{0} combinations", countCombinations);
- Console.WriteLine("Sum: {0}", totalSum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment