VelizarAvramov

12. Test Numbers

Nov 9th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _12._Test_Numbers
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int n = int.Parse(Console.ReadLine());
  10.             int m = int.Parse(Console.ReadLine());
  11.             int maxSum = int.Parse(Console.ReadLine());
  12.             int totalSum = 0;
  13.             int count = 0;
  14.  
  15.             for (int i = n; i >= 1; i--)
  16.             {
  17.                 for (int h = 1; h <= m; h++)
  18.                 {
  19.                     totalSum += (i * h) * 3;
  20.                     count++;
  21.                     if (totalSum >= maxSum)
  22.                     {
  23.                         Console.WriteLine($"{count} combinations");
  24.                         Console.WriteLine($"Sum: {totalSum} >= {maxSum}");
  25.                         return;
  26.                     }
  27.                 }
  28.             }
  29.             Console.WriteLine($"{count} combinations");
  30.             Console.WriteLine($"Sum: {totalSum}");
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment