Advertisement
teotod

Control Number

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