Advertisement
IvanBorisovG

TestNumbers

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