Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int start = Integer.parseInt(scanner.nextLine());
- int end = Integer.parseInt(scanner.nextLine());
- String pattern = "abcde";
- boolean found = false;
- for (int i = 0; i < 5; i++) {
- for (int j = 0; j < 5; j++) {
- for (int k = 0; k < 5; k++) {
- for (int l = 0; l < 5; l++) {
- for (int m = 0; m < 5; m++) {
- String current = "" + pattern.charAt(i) + pattern.charAt(j) + pattern.charAt(k) + pattern.charAt(l) + pattern.charAt(m);
- String unique = "" + current.charAt(0);
- for (int f = 1; f < 5; f++) {
- if (unique.indexOf(current.charAt(f)) == -1) {
- unique = unique + current.charAt(f);
- }
- }
- int add = 0;
- int sum = 0;
- for (int f = 0; f < unique.length(); f++) {
- switch (unique.charAt(f)) {
- case 'a':
- add = 5;
- break;
- case 'b':
- add = -12;
- break;
- case 'c':
- add = 47;
- break;
- case 'd':
- add = 7;
- break;
- case 'e':
- add = -32;
- break;
- }
- sum += (f + 1) * add;
- }
- if (sum >= start && sum <= end) {
- System.out.print(current + " ");
- found = true;
- }
- }
- }
- }
- }
- }
- if (!found){
- System.out.println("No");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement