Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Test {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- int diff = Integer.parseInt(input.nextLine());
- boolean thereIsNoResult = true;
- for (int i = 1; i <= 5; i++) {
- if (i == 2) {
- continue;
- }
- for (int j = 1; j <= 5; j++) {
- if (j == 2) {
- continue;
- }
- for (int j2 = 1; j2 <= 5; j2++) {
- if (j2 == 2) {
- continue;
- }
- for (int k = 1; k <= 5; k++) {
- if (k == 2) {
- continue;
- }
- for (int k2 = 1; k2 <= 5; k2++) {
- if (k2 == 2) {
- continue;
- }
- for (int l = 1; l <= 5; l++) {
- if (l == 2) {
- continue;
- }
- for (int l2 = 1; l2 <= 5; l2++) {
- if (l2 == 2) {
- continue;
- }
- for (int m = 1; m <= 5; m++) {
- if (m == 2) {
- continue;
- }
- if (Math.abs(((i + j + j2 + k) - (k2 + l + l2 + m))) == diff) {
- thereIsNoResult = false;
- PrintDigitAsLetter(i);
- PrintDigitAsLetter(j);
- PrintDigitAsLetter(j2);
- PrintDigitAsLetter(k);
- PrintDigitAsLetter(k2);
- PrintDigitAsLetter(l);
- PrintDigitAsLetter(l2);
- PrintDigitAsLetter(m);
- System.out.println();
- }
- }
- }
- }
- }
- }
- }
- }
- }
- if (thereIsNoResult) {
- System.out.println("No");
- }
- }
- private static void PrintDigitAsLetter(int digit) {
- switch (digit) {
- case 1: System.out.print("k"); break;
- case 3: System.out.print("s"); break;
- case 4: System.out.print("n"); break;
- case 5: System.out.print("p"); break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement