veronikaaa86

12. Test Numbers

Jan 31st, 2018
529
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.22 KB | None | 0 0
  1. namespace Ex12_TestNumbers
  2. {
  3.     using System;
  4.     public class Program
  5.     {
  6.         public static void Main(string[] args)
  7.         {
  8.             int N = int.Parse(Console.ReadLine());
  9.             int M = int.Parse(Console.ReadLine());
  10.             int max = int.Parse(Console.ReadLine());
  11.  
  12.             int sumMultiply = 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.                     counter++;
  20.                     sumMultiply = sumMultiply + (3 * (i * j));
  21.  
  22.                     if (sumMultiply >= max)
  23.                     {
  24.                         break;
  25.                     }
  26.                 }
  27.  
  28.                 if (sumMultiply >= max)
  29.                 {
  30.                     break;
  31.                 }
  32.             }
  33.  
  34.             if (sumMultiply >= max)
  35.             {
  36.                 Console.WriteLine($"{counter} combinations");
  37.                 Console.WriteLine($"Sum: {sumMultiply} >= {max}");
  38.             }
  39.             else
  40.             {
  41.                 Console.WriteLine($"{counter} combinations");
  42.                 Console.WriteLine($"Sum: {sumMultiply}");
  43.             }
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment