Advertisement
nevenailievaa

08. Secret Door's Lock

Mar 6th, 2024
633
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.30 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class P08SecretDoorsLock {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int hundredsDigit = Integer.parseInt(scanner.nextLine());
  7.         int decimalDigit = Integer.parseInt(scanner.nextLine());
  8.         int singlesDigit = Integer.parseInt(scanner.nextLine());
  9.  
  10.         for (int i = 1; i <= hundredsDigit; i++) {
  11.             boolean isValidFirst = i%2==0;
  12.             if (!isValidFirst){
  13.                 continue;
  14.             }
  15.             for (int j = 1; j <= decimalDigit; j++) {
  16.                 int count = 0;
  17.                 for (int l = 1; l <= j; l++) {
  18.                     if (j % l == 0) {
  19.                         count++;
  20.                     }
  21.                 }
  22.                     boolean isValidSecond = count <= 2 && j >=2 && j<=7;
  23.                     if (!isValidSecond){
  24.                         continue;
  25.                     }
  26.                     for (int k = 1; k <= singlesDigit; k++) {
  27.                         boolean isValidThird = k % 2 == 0;
  28.                         if (isValidFirst && isValidSecond&& isValidThird) {
  29.                             System.out.printf("%d %d %d%n", i, j, k);
  30.                         }
  31.                     }
  32.                 }
  33.             }
  34.         }
  35.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement