Advertisement
felix_de_suza

MagicString

May 31st, 2014
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.87 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Test {
  4.  
  5.     public static void main(String[] args) {
  6.    
  7.         Scanner input = new Scanner(System.in);
  8.         int diff = Integer.parseInt(input.nextLine());
  9.        
  10.         boolean thereIsNoResult = true;
  11.        
  12.         for (int i = 1; i <= 5; i++) {
  13.             if (i == 2) {
  14.                 continue;
  15.             }
  16.            
  17.             for (int j = 1; j <= 5; j++) {
  18.                 if (j == 2) {
  19.                     continue;
  20.                 }
  21.                
  22.                 for (int j2 = 1; j2 <= 5; j2++) {
  23.                     if (j2 == 2) {
  24.                         continue;
  25.                     }
  26.                    
  27.                     for (int k = 1; k <= 5; k++) {
  28.                         if (k == 2) {
  29.                             continue;
  30.                         }
  31.                        
  32.                         for (int k2 = 1; k2 <= 5; k2++) {
  33.                             if (k2 == 2) {
  34.                                 continue;
  35.                             }
  36.                            
  37.                             for (int l = 1; l <= 5; l++) {
  38.                                 if (l == 2) {
  39.                                     continue;
  40.                                 }
  41.                                
  42.                                 for (int l2 = 1; l2 <= 5; l2++) {
  43.                                    
  44.                                     if (l2 == 2) {
  45.                                         continue;
  46.                                     }
  47.                                     for (int m = 1; m <= 5; m++) {
  48.                                         if (m == 2) {
  49.                                             continue;
  50.                                         }
  51.                                        
  52.                                         if (Math.abs(((i + j + j2 + k) - (k2 + l + l2 + m))) == diff) {
  53.                                            
  54.                                             thereIsNoResult = false;
  55.                                                                            
  56.                                             PrintDigitAsLetter(i);
  57.                                             PrintDigitAsLetter(j);
  58.                                             PrintDigitAsLetter(j2);
  59.                                             PrintDigitAsLetter(k);
  60.                                             PrintDigitAsLetter(k2);
  61.                                             PrintDigitAsLetter(l);
  62.                                             PrintDigitAsLetter(l2);
  63.                                             PrintDigitAsLetter(m);
  64.                                             System.out.println();
  65.                                            
  66.                                         }
  67.                                        
  68.                                     }
  69.                                 }
  70.                             }
  71.                         }
  72.                     }
  73.                 }
  74.             }
  75.         }
  76.        
  77.         if (thereIsNoResult) {
  78.             System.out.println("No");
  79.         }
  80.        
  81.     }
  82.  
  83.     private static void PrintDigitAsLetter(int digit) {
  84.        
  85.         switch (digit) {
  86.         case 1: System.out.print("k"); break;
  87.         case 3: System.out.print("s"); break;
  88.         case 4: System.out.print("n"); break;
  89.         case 5: System.out.print("p"); break;
  90.         }
  91.        
  92.     }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement