Advertisement
Lyubohd

Untitled

Jun 28th, 2017
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.00 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 ConsoleApp6
  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.  
  19.             for (int i = m; i >= 1; i--)
  20.             {
  21.                 for (int j = n; j >= 1; j--)
  22.                 {
  23.                     for (int k = l; k >= 1; k--)
  24.                     {
  25.                         int number = i * 100 + j * 10 + k;
  26.                         if (number % 3 == 0)
  27.                         {
  28.                             SpecialNumber += 5;
  29.                         }
  30.                         else if (number % 10 == 5)
  31.                         {
  32.                             SpecialNumber = SpecialNumber - 2;
  33.                         }
  34.                         else if (number % 2 == 0)
  35.                         {
  36.                             SpecialNumber = SpecialNumber * 2;
  37.                         }
  38.                         if (SpecialNumber >= ControlNumber)
  39.                         {
  40.                             break;
  41.                         }
  42.                     }
  43.                     if (SpecialNumber >= ControlNumber)
  44.                     {
  45.                         break;
  46.                     }
  47.                 }
  48.                 if (SpecialNumber >= ControlNumber)
  49.                 {
  50.                     break;
  51.                 }
  52.             }
  53.             if (SpecialNumber >= ControlNumber)
  54.             {
  55.                 Console.WriteLine($"Yes! Control number was reached! Current special number is {SpecialNumber}.");
  56.             }
  57.             else Console.WriteLine($"No! {SpecialNumber} is the last reached special number.");
  58.  
  59.         }
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement