Advertisement
kallyy7

Untitled

Feb 25th, 2018
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.53 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.NumberGenerator
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int M = int.Parse(Console.ReadLine());
  14.             int N = int.Parse(Console.ReadLine());
  15.             int L = int.Parse(Console.ReadLine());
  16.             int specialNumber = int.Parse(Console.ReadLine());
  17.             int controlNumber = int.Parse(Console.ReadLine());
  18.             int num = M * 10;
  19.             num += N;
  20.             num *= 10;
  21.             num += L;
  22.             while (num >= 111)
  23.             {
  24.                 if (specialNumber >= controlNumber)
  25.                 {
  26.                     break;
  27.                 }
  28.                 if (num % 3 == 0)
  29.                 {
  30.                     specialNumber += 5;
  31.                 }
  32.                 else if (num % 5 == 0)
  33.                 {
  34.                     specialNumber -= 2;
  35.                 }
  36.                 else if (num % 2 == 0 && num != 1)
  37.                 {
  38.                     specialNumber *= 2;
  39.                 }
  40.                 num--;              
  41.             }
  42.             if (specialNumber < controlNumber)
  43.             {
  44.                 Console.WriteLine($"No! {specialNumber} is the last reached special number.");
  45.             }
  46.             else
  47.             {
  48.                 Console.WriteLine($"Yes! Control number was reached! Current special number is {specialNumber}.");
  49.             }
  50.         }
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement