Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Control_Number
- {
- class Program
- {
- static void Main(string[] args)
- {
- int N = int.Parse(Console.ReadLine());
- int M = int.Parse(Console.ReadLine());
- int ControlNumber = int.Parse(Console.ReadLine());
- int counter = 0;
- int sum = 0;
- int endSum = 0;
- for (int i = 1; i <= N; i++)
- {
- for (int j = M; j >= 1; j--)
- {
- sum = i * 2 + j * 3;
- endSum += sum;
- counter++;
- if (endSum >= ControlNumber)
- {
- break;
- }
- }
- if (endSum >= ControlNumber)
- {
- break;
- }
- }
- if (endSum >= ControlNumber)
- {
- Console.WriteLine("{0} moves", counter);
- Console.WriteLine("Score: {0} >= {1}", endSum, ControlNumber);
- }
- else
- {
- Console.WriteLine("{0} moves", counter);
- }
- }
- }
- }
- /*
- int n = int.Parse(Console.ReadLine());
- int m = int.Parse(Console.ReadLine());
- var controlNum = decimal.Parse(Console.ReadLine());
- var counter = 0;
- var sum = 0;
- for (int i = n; i <= m; i++)
- {
- for (int j = n; j <= m; j++)
- {
- counter++;
- sum = (i + j);
- if (sum == controlNum)
- {
- Console.Write($"Combination N:{counter} ");
- Console.WriteLine($"({i} + {j} = {sum})");
- break;
- }
- }
- if (sum == controlNum)
- break;
- }
- if (sum != controlNum)
- Console.WriteLine($"{counter} combinations - neither equals {magicNumber}");
- }
- }
- }*/
Advertisement
Add Comment
Please, Sign In to add comment