Advertisement
ktopchiev

TestNumbers

Jan 30th, 2018
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.18 KB | None | 0 0
  1. using System;
  2.  
  3. namespace TestNumbers
  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 boundary = int.Parse(Console.ReadLine());
  12.             int multiplier = 3, product = 1, result = 1, totalSum = 0, counter = 0;
  13.  
  14.             for (int i = n; i >= 1; i--)
  15.             {
  16.                 for (int j = 1; j <= m; j++)
  17.                 {
  18.                     if (totalSum >= boundary)
  19.                     {
  20.                         break;
  21.                     }
  22.                     product = i * j;
  23.                     result = multiplier * product;
  24.                     totalSum += result;
  25.                     counter++;
  26.                 }
  27.             }
  28.             if (totalSum >= boundary)
  29.             {
  30.                 Console.WriteLine($"{counter} combinations");
  31.                 Console.WriteLine($"Sum: {totalSum} >= {boundary}");
  32.             }
  33.             else
  34.             {
  35.                 Console.WriteLine($"{counter} combinations");
  36.                 Console.WriteLine($"Sum: {totalSum}");
  37.             }
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement