Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class P08SecretDoorsLock {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int hundredsDigit = Integer.parseInt(scanner.nextLine());
- int decimalDigit = Integer.parseInt(scanner.nextLine());
- int singlesDigit = Integer.parseInt(scanner.nextLine());
- for (int i = 1; i <= hundredsDigit; i++) {
- boolean isValidFirst = i%2==0;
- if (!isValidFirst){
- continue;
- }
- for (int j = 1; j <= decimalDigit; j++) {
- int count = 0;
- for (int l = 1; l <= j; l++) {
- if (j % l == 0) {
- count++;
- }
- }
- boolean isValidSecond = count <= 2 && j >=2 && j<=7;
- if (!isValidSecond){
- continue;
- }
- for (int k = 1; k <= singlesDigit; k++) {
- boolean isValidThird = k % 2 == 0;
- if (isValidFirst && isValidSecond&& isValidThird) {
- System.out.printf("%d %d %d%n", i, j, k);
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement