Advertisement
martinvalchev

Test_Numbers

Jan 30th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.86 KB | None | 0 0
  1. using System;
  2.  
  3. namespace 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 sumMax = int.Parse(Console.ReadLine());
  12.             int sum = 0;
  13.             int counter = 0;
  14.  
  15.             for (int i = n; i >= 1; i--)
  16.             {
  17.                 for (int j = 1; j <= m; j++)
  18.                 {
  19.                     sum += i * j * 3;
  20.                     counter++;
  21.                     if (sum >= sumMax)
  22.                     {
  23.                         Console.WriteLine($"{counter} combinations\r\nSum: {sum} >= {sumMax}");
  24.                         return;
  25.                     }
  26.                 }
  27.             }
  28.             Console.WriteLine($"{counter} combinations\r\nSum: {sum}");
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement