Advertisement
kera123

Number Generator

Dec 15th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | None | 0 0
  1. using System;
  2.                    
  3. public class Program
  4. {
  5.     public static void Main()
  6.     {
  7.         int n = int.Parse(Console.ReadLine());
  8.         int m = int.Parse(Console.ReadLine());
  9.         int l = int.Parse(Console.ReadLine());
  10.         int special = int.Parse(Console.ReadLine());
  11.         int control = int.Parse(Console.ReadLine());
  12.         int sumator = 0;
  13.        
  14.         for(int i = n; i >= 1; i --)
  15.         {
  16.             for(int j = m; j >= 1; j --)
  17.             {
  18.                 for(int k = l; k >= 1; k --)
  19.                 {
  20.                     sumator = 100 * i + 10 * j + k;
  21.                    
  22.                     if(sumator % 3 == 0)                   
  23.                     {
  24.                         special += 5;
  25.                     }  
  26.                     else if(sumator % 10 == 5)
  27.                     {
  28.                         special -= 2;
  29.                     }
  30.                     else if(sumator % 2 == 0)
  31.                     {
  32.                         special *= 2;
  33.                     }
  34.                     if(special >= control)
  35.                     {
  36.                     Console.WriteLine("Yes! Control number was reached! Current special number is {0}.", special);
  37.                     return;
  38.                     }
  39.                 }
  40.             }
  41.         }
  42.        
  43.         Console.WriteLine("No! {0} is the last reached special number.", special);
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement