Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Number_Generator
- {
- class Number_Generator
- {
- static void Main(string[] args)
- {
- int M = int.Parse(Console.ReadLine());
- int N = int.Parse(Console.ReadLine());
- int L = int.Parse(Console.ReadLine());
- int specialNumber = int.Parse(Console.ReadLine());
- int controlNumber = int.Parse(Console.ReadLine());
- int number = 0;
- for (int i = M; i >= 1; i--)
- {
- for (int j = N; j >= 1; j--)
- {
- for (int k = L; k >= 1; k--)
- {
- number = int.Parse(Convert.ToString(i) + Convert.ToString(j) + Convert.ToString(k));
- bool priority1 = number % 3 == 0;
- bool priority2 = number % 10 == 5;
- bool priority3 = number % 2 == 0;
- if (specialNumber >= controlNumber) break;
- if (priority1 || priority1 && priority2 || priority1 && priority3 || priority1 && priority2 && priority3) specialNumber += 5;
- else if (priority2 || priority2 && priority3) specialNumber -= 2;
- else if (priority3) specialNumber *= 2;
- }
- if (specialNumber >= controlNumber) break;
- }
- if (specialNumber >= controlNumber) break;
- }
- if (specialNumber >= controlNumber)
- {
- Console.WriteLine($"Yes! Control number was reached! Current special number is {specialNumber}.");
- return;
- }
- else
- {
- Console.WriteLine($"No! {specialNumber} is the last reached special number.");
- return;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment