Advertisement
ines914618

Untitled

Jul 21st, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.19 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.CompilerServices;
  5. using System.Runtime.InteropServices;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8.  
  9. namespace BasicsStuff1
  10. {
  11.     class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.  
  16.             int m = int.Parse(Console.ReadLine());
  17.             int n = int.Parse(Console.ReadLine());
  18.             int l = int.Parse(Console.ReadLine());
  19.             int specialNum = int.Parse(Console.ReadLine());
  20.             int contol = int.Parse(Console.ReadLine());
  21.  
  22.             bool isReached = false;
  23.  
  24.            
  25.            
  26.  
  27.             for (int i = m; i >= 1; i--)
  28.             {
  29.                 for (int j = n; j >= 1; j--)
  30.                 {
  31.                     for (int k = l; k >= 1; k--)
  32.                     {
  33.                         string a = i.ToString() + j.ToString() + k.ToString();
  34.                         if (int.Parse(a)% 3 == 0)
  35.                         {
  36.                             specialNum = specialNum + 5;
  37.                         }
  38.                         else if ( k== 5)
  39.                         {
  40.                             specialNum = specialNum - 2;
  41.                         }
  42.                         else if (k %2 == 0)
  43.                         {
  44.                             specialNum = specialNum * 2;
  45.                         }
  46.  
  47.                         if (specialNum >= contol)
  48.                         {
  49.                             isReached = true;
  50.                             break;
  51.                         }
  52.                     }
  53.                     if (isReached)
  54.                     {
  55.                         break;
  56.                     }
  57.                 }
  58.                 if (isReached)
  59.                 {
  60.                     break;
  61.                 }
  62.                
  63.             }
  64.  
  65.             if (isReached)
  66.             {
  67.                
  68.                 Console.WriteLine($"Yes! Control number was reached! Current special number is {specialNum}.");
  69.             }
  70.             else
  71.             {
  72.                 Console.WriteLine($"No! {specialNum} is the last reached special number.");
  73.  
  74.             }
  75.  
  76.  
  77.         }
  78.  
  79.  
  80.     }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement