package t08_ExamPreparations.e06_7_May_2017;

import java.util.Scanner;

public class p06_NumberGenerator {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int m = Integer.parseInt(scan.nextLine());
        int n = Integer.parseInt(scan.nextLine());
        int l = Integer.parseInt(scan.nextLine());
        int special = Integer.parseInt(scan.nextLine());
        int control = Integer.parseInt(scan.nextLine());

        for (int i = 1; i <= m; i++) {
            for (int j = 1; j <= n; j++) {
                for (int k = 1; k <= l; k++) {
                    if ((i + j + k) % 3 == 0) {
                        special += 2;
                    }

                    if (k % 2 == 0) {
                        special *= 2;
                    }

                    if (k % 5 == 0) {
                        special -= 2;
                    }

                }
            }
        }
    }
}

@@ -461,16 +461,51 @@
 ne());%0A%0A
+        boolean isReached = false;%0A
         
@@ -521,22 +521,22 @@
 i = 
-1
+m
 ; i 
-%3C= m; i++
+%3E= 1; i--
 ) %7B%0A
@@ -564,22 +564,22 @@
 j = 
-1
+n
 ; j 
-%3C= n; j++
+%3E= 1; j--
 ) %7B%0A
@@ -611,26 +611,136 @@
 k = 
-1
+l
 ; k 
-%3C= l; k++
+%3E= 1; k--
 ) %7B%0A
+                    if(special %3E= control) %7B%0A                        isReached = true;%0A                    %7D%0A%0A
     
@@ -818,17 +818,17 @@
 cial += 
-2
+5
 ;%0A      
@@ -834,33 +834,93 @@
                %7D
-%0A
+ else if (k %25 5 == 0) %7B%0A                        special -= 2;
 %0A               
@@ -916,32 +916,39 @@
                 
+%7D else 
 if (k %25 2 == 0) 
@@ -1002,32 +1002,33 @@
              %7D%0A%0A
+%0A
                 
@@ -1014,32 +1014,40 @@
  %7D%0A%0A%0A           
+     %7D%0A%0A
          if (k %25
@@ -1039,33 +1039,103 @@
         
-if (k %25 5 == 0) %7B
+       if(special %3E= control) %7B%0A                    isReached = true;%0A                %7D
 %0A       
@@ -1131,32 +1131,35 @@
   %7D%0A            
+%7D%0A%0A
             spec
@@ -1150,32 +1150,35 @@
             
+if(
 special 
 -= 2;%0A      
@@ -1157,36 +1157,78 @@
      if(special 
--= 2
+%3E= control) %7B%0A                isReached = true
 ;%0A              
@@ -1217,32 +1217,34 @@
 ue;%0A            
+%7D%0A
         %7D%0A%0A     
@@ -1246,39 +1246,241 @@
         
-        %7D%0A            %7D
+if(isReached) %7B%0A            System.out.printf(%22Yes! Control number was reached! Current special number is %25d.%22, special);%0A        %7D else %7B%0A            System.out.printf(%22%E2%80%9CNo! %25d is the last reached special number.%22, special);
 %0A       

task 6