koksibg

Number_Generator

Nov 1st, 2017
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.89 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Number_Generator
  4. {
  5.     class Number_Generator
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int M = int.Parse(Console.ReadLine());
  10.             int N = int.Parse(Console.ReadLine());
  11.             int L = int.Parse(Console.ReadLine());
  12.             int specialNumber = int.Parse(Console.ReadLine());
  13.             int controlNumber = int.Parse(Console.ReadLine());
  14.             int number = 0;
  15.             for (int i = M; i >= 1; i--)
  16.             {
  17.                 for (int j = N; j >= 1; j--)
  18.                 {
  19.                     for (int k = L; k >= 1; k--)
  20.                     {
  21.                         number = int.Parse(Convert.ToString(i) + Convert.ToString(j) + Convert.ToString(k));
  22.                         bool priority1 = number % 3 == 0;
  23.                         bool priority2 = number % 10 == 5;
  24.                         bool priority3 = number % 2 == 0;
  25.                         if (specialNumber >= controlNumber) break;                                            
  26.                         if (priority1 || priority1 && priority2 || priority1 && priority3 || priority1 && priority2 && priority3) specialNumber += 5;
  27.                         else if (priority2 || priority2 && priority3) specialNumber -= 2;
  28.                         else if (priority3) specialNumber *= 2;
  29.                     }
  30.                     if (specialNumber >= controlNumber) break;
  31.                 }
  32.                 if (specialNumber >= controlNumber) break;
  33.             }
  34.             if (specialNumber >= controlNumber)
  35.             {
  36.                 Console.WriteLine($"Yes! Control number was reached! Current special number is {specialNumber}.");
  37.                 return;
  38.             }
  39.             else
  40.             {
  41.                 Console.WriteLine($"No! {specialNumber} is the last reached special number.");
  42.                 return;
  43.             }
  44.         }
  45.     }
  46. }
Add Comment
Please, Sign In to add comment