Advertisement
Spocoman

Number Generator

Sep 8th, 2024
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.26 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int m = Integer.parseInt(scanner.nextLine()),
  7.                 n = Integer.parseInt(scanner.nextLine()),
  8.                 l = Integer.parseInt(scanner.nextLine()),
  9.                 special = Integer.parseInt(scanner.nextLine()),
  10.                 control = Integer.parseInt(scanner.nextLine());
  11.  
  12.         for (int i = m; i > 0; i--) {
  13.             for (int j = n; j > 0; j--) {
  14.                 for (int k = l; k > 0; k--) {
  15.                     int num = i * 100 + j * 10 + k;
  16.  
  17.                     if (num % 3 == 0) {
  18.                         special += 5;
  19.                     } else if (num % 5 == 0) {
  20.                         special -= 2;
  21.                     } else if (num % 2 == 0) {
  22.                         special *= 2;
  23.                     }
  24.  
  25.                     if (special >= control) {
  26.                         System.out.println("Yes! Control number was reached! Current special number is " + special + ".");
  27.                         System.exit(0);
  28.                     }
  29.                 }
  30.             }
  31.         }
  32.  
  33.         System.out.println("No! " + special + " is the last reached special number.");
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement