Advertisement
ktopchiev

Problem 06 - Control Number

Dec 13th, 2017
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.16 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Problem_01___Grape_and_Rakia
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int n = int.Parse(Console.ReadLine());
  14.             int m = int.Parse(Console.ReadLine());
  15.             int controlNum = int.Parse(Console.ReadLine());
  16.             int sum = 0;
  17.             int moves = 0;
  18.  
  19.             for (int i = 1; i <= n; i++)
  20.             {
  21.                 int a = i * 2;
  22.                 for (int j = m; j >= 1; j--)
  23.                 {
  24.                    int b = j * 3;
  25.                     sum = a + b + sum;
  26.                     moves++;
  27.                     if (sum >= controlNum) break;
  28.                 }
  29.                 if (sum >= controlNum) break;
  30.             }
  31.             if (sum >= controlNum)
  32.             {
  33.                 Console.WriteLine(moves + " moves");
  34.                 Console.WriteLine($"Score: {sum} >= {controlNum}");
  35.             }
  36.             else if (sum < controlNum)
  37.             {
  38.                 Console.WriteLine(moves + " moves");
  39.             }
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement