Advertisement
kallyy7

Untitled

Feb 25th, 2018
143
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 _06.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 moves = 0;
  17.             int sum = 0;
  18.  
  19.             for (int a = 1; a <= N; a++)
  20.             {
  21.                 for (int b = M; b >= 1; b--)
  22.                 {
  23.                     if (sum >= controlNumber)
  24.                     {
  25.                         Console.WriteLine($"{moves} moves");
  26.                         Console.WriteLine($"Score: {sum} >= {controlNumber}");
  27.                         break;
  28.                     }
  29.                     sum = sum + (a * 2) + (b * 3);
  30.                     moves += 1;
  31.                 }
  32.             }
  33.             if (sum < controlNumber)
  34.             {
  35.                 Console.WriteLine($"{moves} moves");
  36.             }
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement