rado8506

06. Control Number

Feb 23rd, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.08 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 ConsoleApp38
  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 control = int.Parse(Console.ReadLine());
  16.  
  17.             int sum = 0;
  18.             int count = 0;
  19.             for (int i = 1; i <= n; i++)
  20.             {
  21.                 for (int j = m; j >= 1; j--)
  22.                 {
  23.                     if (sum>=control)
  24.                     {
  25.                         break;
  26.                     }
  27.                     sum = sum + (i * 2) + (j * 3);
  28.                     count++;
  29.                 }
  30.             }
  31.             if (sum >= control)
  32.             {
  33.                 Console.WriteLine($"{count} moves");
  34.                 Console.WriteLine($"Score: {sum} >= {control}");
  35.             }
  36.             else
  37.             {
  38.                 Console.WriteLine($"{count} moves");
  39.             }
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment