Advertisement
filipovv

testNums

May 31st, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 KB | None | 0 0
  1. using System;
  2.  
  3. namespace TestNums
  4. {
  5.     class MainClass
  6.     {
  7.         public static void Main(string[] args)
  8.         {
  9.             int n = int.Parse(Console.ReadLine());
  10.             int m = int.Parse(Console.ReadLine());
  11.             int max = int.Parse(Console.ReadLine());
  12.  
  13.             int sum = 0;
  14.             int counter = 0;
  15.  
  16.  
  17.             for (int i = n; i >= 1 ; i--)
  18.             {
  19.                 for (int j = 1; j <= m; j++)
  20.                 {
  21.                     sum = sum + (3 * (j * i));
  22.                     counter++;
  23.                     if (sum >= max)
  24.                     {
  25.                         break;
  26.                     }
  27.                 }
  28.                 if (sum>=max)
  29.                 {
  30.                     break;
  31.                 }
  32.             }
  33.             if (sum>=max)
  34.             {
  35.                 Console.WriteLine($"{counter} combinations\nSum: {sum} >= {max}");
  36.             }
  37.             else
  38.             {
  39.                 Console.WriteLine($"{counter} combinations\nSum: {sum}");
  40.  
  41.             }
  42.  
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement